mirror of https://github.com/pwndbg/pwndbg.git
Move file.py to gdblib and improve procinfo test (#1258)
parent
bb342a9286
commit
63b988a997
@ -1,5 +1,5 @@
|
||||
:mod:`pwndbg.file` --- pwndbg.file
|
||||
:mod:`pwndbg.gdblib.file` --- pwndbg.gdblib.file
|
||||
=============================================
|
||||
|
||||
.. automodule:: pwndbg.file
|
||||
.. automodule:: pwndbg.gdblib.file
|
||||
:members:
|
||||
|
||||
@ -0,0 +1,24 @@
|
||||
import pwndbg.gdblib.file
|
||||
import pwndbg.lib.net
|
||||
|
||||
|
||||
def tcp():
|
||||
# For reference, see:
|
||||
# https://www.kernel.org/doc/Documentation/networking/proc_net_tcp.txt
|
||||
"""
|
||||
It will first list all listening TCP sockets, and next list all established
|
||||
TCP connections. A typical entry of /proc/net/tcp would look like this (split
|
||||
up into 3 parts because of the length of the line):
|
||||
"""
|
||||
data = pwndbg.gdblib.file.get("/proc/net/tcp").decode()
|
||||
return pwndbg.lib.net.tcp(data)
|
||||
|
||||
|
||||
def unix():
|
||||
data = pwndbg.gdblib.file.get("/proc/net/unix").decode()
|
||||
return pwndbg.lib.net.unix(data)
|
||||
|
||||
|
||||
def netlink():
|
||||
data = pwndbg.gdblib.file.get("/proc/net/netlink").decode()
|
||||
return pwndbg.lib.net.netlink(data)
|
||||
@ -1,8 +1,36 @@
|
||||
#include <arpa/inet.h>
|
||||
#include <stdio.h>
|
||||
|
||||
void foo() {}
|
||||
#define PORT 80
|
||||
|
||||
int main() {
|
||||
puts("Hello world");
|
||||
foo();
|
||||
void break_here() {};
|
||||
|
||||
int main(int argc, char const* argv[]) {
|
||||
puts("Hello World");
|
||||
|
||||
int sock = 0, client_fd;
|
||||
struct sockaddr_in serv_addr;
|
||||
|
||||
if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
|
||||
perror("socket");
|
||||
return -1;
|
||||
}
|
||||
|
||||
serv_addr.sin_family = AF_INET;
|
||||
serv_addr.sin_port = htons(PORT);
|
||||
|
||||
if (inet_pton(AF_INET, "1.1.1.1", &serv_addr.sin_addr) <= 0) {
|
||||
perror("inet_pton");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((client_fd = connect(sock, (struct sockaddr*)&serv_addr, sizeof(serv_addr))) < 0) {
|
||||
perror("connect");
|
||||
return -1;
|
||||
}
|
||||
|
||||
break_here();
|
||||
|
||||
close(client_fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Loading…
Reference in new issue