Skip to content

Commit

Permalink
added some forgotten strings protection
Browse files Browse the repository at this point in the history
  • Loading branch information
itaymigdal committed Feb 16, 2024
1 parent e514371 commit b1becd5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions PichichiH0ll0wer/Loader/mailslot.nim
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import winim
import strutils
import nimprotect


proc createMailslot*(mailslotPath: string): HANDLE =
let mailslotHandle = CreateMailslot(mailslotPath, 0, 0, nil)
if mailslotHandle == INVALID_HANDLE_VALUE:
echo "[-] Failed to create mailslot: ", GetLastError()
echo protectString("[-] Failed to create mailslot: "), GetLastError()
return 0
return mailslotHandle

Expand All @@ -22,7 +23,7 @@ proc readMailslot*(mailslotHandle: HANDLE): string =
nil
)
if bytesRead == 0:
echo "[-] Failed to read from mailslot: ", GetLastError()
echo protectString("[-] Failed to read from mailslot: "), GetLastError()
return ""
return messageBuffer[0 .. int(bytesRead)-1].join("")

Expand All @@ -31,7 +32,7 @@ proc writeMailslot*(mailslotPath: string, message: string): bool =
# Write to the mailslot
let mailslotHandle = CreateFile(mailslotPath, GENERIC_WRITE, FILE_SHARE_READ, nil, OPEN_EXISTING, 0, 0)
if mailslotHandle == INVALID_HANDLE_VALUE:
echo "[-] Failed to open mailslot for writing: ", GetLastError()
echo protectString("[-] Failed to open mailslot for writing: "), GetLastError()
return false
var lpNumberOfBytesWritten: DWORD
discard WriteFile(
Expand All @@ -42,7 +43,7 @@ proc writeMailslot*(mailslotPath: string, message: string): bool =
nil
)
if lpNumberOfBytesWritten == 0:
echo "[-] Failed to write to mailslot: ", GetLastError()
echo protectString("[-] Failed to write to mailslot: "), GetLastError()
return false
CloseHandle(mailslotHandle)
return true
Expand Down

0 comments on commit b1becd5

Please sign in to comment.