tomovic
Anmeldungsdatum: 25. August 2013
Beiträge: 238
|
hallo,
ich möchte flogendes compilieren:
root@tomvic:/test# gcc $(libnet-config --defines) -o shroud shroud.c -lnet -lpcap
Die Anwendung »libnet-config« ist momentan nicht installiert. Sie können sie durch folgende Eingabe installieren:
apt-get install libnet1-dev
root@tomvic:/test# apt-get install libnet1-dev
Paketlisten werden gelesen... Fertig
Abhängigkeitsbaum wird aufgebaut.
Statusinformationen werden eingelesen.... Fertig
Die folgenden NEUEN Pakete werden installiert:
libnet1-dev
0 aktualisiert, 1 neu installiert, 0 zu entfernen und 212 nicht aktualisiert.
Es müssen 115 kB an Archiven heruntergeladen werden.
Nach dieser Operation werden 435 kB Plattenplatz zusätzlich benutzt.
Holen: 1 http://de.archive.ubuntu.com/ubuntu/ raring/main libnet1-dev i386 1.1.4-2.1build1 [115 kB]
Es wurden 115 kB in 0 s geholt (423 kB/s).
Vormals nicht ausgewähltes Paket libnet1-dev wird gewählt.
(Lese Datenbank ... 160056 Dateien und Verzeichnisse sind derzeit installiert.)
Entpacken von libnet1-dev (aus .../libnet1-dev_1.1.4-2.1build1_i386.deb) ...
Trigger für man-db werden verarbeitet ...
libnet1-dev (1.1.4-2.1build1) wird eingerichtet ...
root@tomvic:/test# gcc $(libnet-config --defines) -o shroud shroud.c -lnet -lpcap
shroud.c:2:18: Schwerwiegender Fehler: pcap.h: Datei oder Verzeichnis nicht gefunden
Kompilierung beendet.
root@tomvic:/test#
-lnet und -lpcat greift auf das System zu stimmt das? Bearbeitet von rklm: Ordentliche Formatierung. Bitte demnächst selbst machen. Die Vorschaufunktion leistet auch gute Dienste. 😬
|
lubux
Anmeldungsdatum: 21. November 2012
Beiträge: 14369
|
tomovic schrieb: ...:/test# gcc $(libnet-config --defines) -o shroud shroud.c -lnet -lpcap
shroud.c:2:18: Schwerwiegender Fehler: pcap.h: Datei oder Verzeichnis nicht gefunden
Kompilierung beendet. -lnet und -lpcat greift auf das System zu stimmt das?
Wie sind die Ausgaben für:
apt-get -s install libpcap-dev
sudo apt-get -f install
?
|
tomovic
(Themenstarter)
Anmeldungsdatum: 25. August 2013
Beiträge: 238
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 |
root@tomovic# apt-get -s install libpcap-dev
Paketlisten werden gelesen... Fertig
Abhängigkeitsbaum wird aufgebaut.
Statusinformationen werden eingelesen.... Fertig
Die folgenden zusätzlichen Pakete werden installiert:
libpcap0.8-dev
Die folgenden NEUEN Pakete werden installiert:
libpcap-dev libpcap0.8-dev
0 aktualisiert, 2 neu installiert, 0 zu entfernen und 212 nicht aktualisiert.
Inst libpcap0.8-dev (1.3.0-1 Ubuntu:13.04/raring [i386])
Inst libpcap-dev (1.3.0-1 Ubuntu:13.04/raring [all])
Conf libpcap0.8-dev (1.3.0-1 Ubuntu:13.04/raring [i386])
Conf libpcap-dev (1.3.0-1 Ubuntu:13.04/raring [all])
root@tomovic# sudo apt-get -f install
Paketlisten werden gelesen... Fertig
Abhängigkeitsbaum wird aufgebaut.
Statusinformationen werden eingelesen.... Fertig
0 aktualisiert, 0 neu installiert, 0 zu entfernen und 212 nicht aktualisiert.
root@tomovic# gcc $(libnet-config --defines) -o shroud shroud.c -lnet -lpcap
shroud.c:2:18: Schwerwiegender Fehler: pcap.h: Datei oder Verzeichnis nicht gefunden
Kompilierung beendet.
root@tomovic#
Code
|
|
lubux
Anmeldungsdatum: 21. November 2012
Beiträge: 14369
|
tomovic schrieb: root@tomovic# sudo apt-get -f install
Paketlisten werden gelesen... Fertig
Abhängigkeitsbaum wird aufgebaut.
Statusinformationen werden eingelesen.... Fertig
0 aktualisiert, 0 neu installiert, 0 zu entfernen und 212 nicht aktualisiert.
root@tomovic# gcc $(libnet-config --defines) -o shroud shroud.c -lnet -lpcap
shroud.c:2:18: Schwerwiegender Fehler: pcap.h: Datei oder Verzeichnis nicht gefunden
Kompilierung beendet.
root@tomovic#
Warum als root? Wie ist die Ausgabe für:
ls -la /usr/include/pcap.h
?
|
tomovic
(Themenstarter)
Anmeldungsdatum: 25. August 2013
Beiträge: 238
|
|
lubux
Anmeldungsdatum: 21. November 2012
Beiträge: 14369
|
tomovic schrieb: root@tomovic# gcc $(libnet-config --defines) -o shroud shroud.c -lnet -lpcap
shroud.c:2:18: Schwerwiegender Fehler: pcap.h: Datei oder Verzeichnis nicht gefunden
Kompilierung beendet.
root@tomovic#
Warum als root? EDIT: Die Ausgabe für:
ls -la /usr/include/pcap/pcap.h
? EDIT 2: BTW:
-s, --simulate, --just-print, --dry-run, --recon, --no-act
Weder NoLocking noch die Mitteilung werden ausgelöst, wenn es als root ausgeführt wird (root
sollte ohne weitere Warnungen von apt-get wissen, was er tut).
|
tomovic
(Themenstarter)
Anmeldungsdatum: 25. August 2013
Beiträge: 238
|
Wieder datei nicht gefunden,
ich nehme root weil ich alle rechte habe und nicht immer su eingeben muss. In meinem ganzen System habe ich 4 pcap.h Dateien gefunden, aber mit 0 Byte.
/usr/src/linux-headers-3.8.0-19/include/linux/mfd ist ezx-pcap.h
|
lubux
Anmeldungsdatum: 21. November 2012
Beiträge: 14369
|
tomovic schrieb: ich nehme root weil ich alle rechte habe und nicht immer su eingeben muss.
Du brauchst aber nur ganz selten alle Rechte. Z. B., warum willst Du als root, shroud kompilieren?
|
tomovic
(Themenstarter)
Anmeldungsdatum: 25. August 2013
Beiträge: 238
|
ich weiß dass ich selten rootrechte brauche.wenn man oefters Programme kompiliert und das Netzwerk naeher kennenlernt ist root nicht von Nachteil. hast du noch einen tip fuer die Header Datei pcap.h ?
|
lubux
Anmeldungsdatum: 21. November 2012
Beiträge: 14369
|
tomovic schrieb: hast du noch einen tip fuer die Header Datei pcap.h ?
Versuch mal als normaler Anwender (... d. h. nicht als root!):
sudo apt-get clean
sudo apt-get update && sudo apt-get dist-upgrade
sudo apt-get -f install
apt-get -s install libpcap-dev
ls -la /usr/include/pcap.h EDIT: BTW: Der "alte" source code aus "shroud.c" wird mit der aktuellen libnet1-dev evtl. nicht funktionieren.
|
tomovic
(Themenstarter)
Anmeldungsdatum: 25. August 2013
Beiträge: 238
|
|
lubux
Anmeldungsdatum: 21. November 2012
Beiträge: 14369
|
tomovic schrieb: Datei nicht gefunden.
Wie sind im Terminal, die Ausgaben von:
sudo apt-get -f install
apt-get -s install libpcap-dev
, wenn Du als normaler Anwender (... d. h. nicht als root) angemeldet bist?
|
rklm
Projektleitung
Anmeldungsdatum: 16. Oktober 2011
Beiträge: 13212
|
tomovic schrieb: ich weiß dass ich selten rootrechte brauche.wenn man oefters Programme kompiliert und das Netzwerk naeher kennenlernt ist root nicht von Nachteil.
Da bin ich ganz anderer Meinung: je kürzer man "root" ist, desto besser. Insbesondere kann man sich nicht versehentlich wichtige Systemteile zerschießen, wenn man nicht als "root" übersetzt. Ciao robert
|
tomovic
(Themenstarter)
Anmeldungsdatum: 25. August 2013
Beiträge: 238
|
| game@L300:/home$ sudo apt-get -f install
[sudo] password for game:
game is not in the sudoers file. This incident will be reported.
game@-L300:/home$ sudo apt-get -s install libpcap-dev
[sudo] password for game:
game is not in the sudoers file. This incident will be reported.
game@-L300:/home$
|
mit root gings ☺
wenn mein uraltes c Prog sowieso nicht läuft, dann kann ich ja aufhören, oder?
|
tomovic
(Themenstarter)
Anmeldungsdatum: 25. August 2013
Beiträge: 238
|
ich habe jetzt MUT zusammengefasst und will nicht aufgeben, vielleicht gehts ja doch.
Meine installierte Packte: apt-get install libdnet-dev
apt-get install libpcap-dev und dann habe ich noch libnet installiet. jetzt kommt folgede Meldung:
1
2
3
4
5
6
7
8
9
10
11
12
13
14 | root@tomovic# gcc $(libnet-config --defines) -o shroud shroud.c -lnet -lpcap
shroud.c:(.text+0x20f): undefined reference to `libnet_name_resolve'
shroud.c:(.text+0x2f2): undefined reference to `libnet_open_raw_sock'
shroud.c:(.text+0x313): undefined reference to `libnet_error'
shroud.c:(.text+0x32a): undefined reference to `libnet_init_packet'
shroud.c:(.text+0x346): undefined reference to `libnet_error'
/tmp/ccq2WcsT.o: In function `caught_packet':
shroud.c:(.text+0x741): undefined reference to `libnet_build_ip'
shroud.c:(.text+0x824): undefined reference to `libnet_error'
shroud.c:(.text+0x843): undefined reference to `libnet_write_ip'
shroud.c:(.text+0x860): undefined reference to `libnet_error'
collect2: Fehler: ld gab 1 als Ende-Status zurück
root@tomovick#
|
die c datei...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139 | #include <libnet.h>
#include <pcap.h>
#include "hacking.h"
#define MAX_EXISTING_PORTS 30
void caught_packet(u_char *, const struct pcap_pkthdr *, const u_char *);
int set_packet_filter(pcap_t *, struct in_addr *, u_short *);
struct data_pass {
int libnet_handle;
u_char *packet;
};
int main(int argc, char *argv[]) {
struct pcap_pkthdr cap_header;
const u_char *packet, *pkt_data;
pcap_t *pcap_handle;
char errbuf[PCAP_ERRBUF_SIZE]; // same size as LIBNET_ERRBUF_SIZE
char *device;
u_long target_ip;
int network, i;
struct data_pass critical_libnet_data;
u_short existing_ports[MAX_EXISTING_PORTS];
if((argc < 2) || (argc > MAX_EXISTING_PORTS+2)) {
if(argc > 2)
printf("Limited to tracking %d existing ports.\n", MAX_EXISTING_PORTS);
else
printf("Usage: %s <IP to shroud> [existing ports...]\n", argv[0]);
exit(0);
}
target_ip = libnet_name_resolve(argv[1], LIBNET_RESOLVE);
if (target_ip == -1)
fatal("Invalid target address");
for(i=2; i < argc; i++)
existing_ports[i-2] = (u_short) atoi(argv[i]);
existing_ports[argc-2] = 0;
device = pcap_lookupdev(errbuf);
if(device == NULL)
fatal(errbuf);
pcap_handle = pcap_open_live(device, 128, 1, 0, errbuf);
if(pcap_handle == NULL)
fatal(errbuf);
critical_libnet_data.libnet_handle = libnet_open_raw_sock(IPPROTO_RAW);
if(critical_libnet_data.libnet_handle == -1)
libnet_error(LIBNET_ERR_FATAL, "can't open network interface. -- this program must run as root.\n");
libnet_init_packet(LIBNET_IP_H + LIBNET_TCP_H, &(critical_libnet_data.packet));
if (critical_libnet_data.packet == NULL)
libnet_error(LIBNET_ERR_FATAL, "can't initialize packet memory.\n");
libnet_seed_prand();
set_packet_filter(pcap_handle, (struct in_addr *)&target_ip, existing_ports);
pcap_loop(pcap_handle, -1, caught_packet, (u_char *)&critical_libnet_data);
pcap_close(pcap_handle);
}
/* sets a packet filter to look for established TCP connections to target_ip */
int set_packet_filter(pcap_t *pcap_hdl, struct in_addr *target_ip, u_short *ports) {
struct bpf_program filter;
char *str_ptr, filter_string[90 + (25 * MAX_EXISTING_PORTS)];
int i=0;
sprintf(filter_string, "dst host %s and ", inet_ntoa(*target_ip)); // target IP
strcat(filter_string, "tcp[tcpflags] & tcp-syn != 0 and tcp[tcpflags] & tcp-ack = 0");
if(ports[0] != 0) { // if there is at least one existing port
str_ptr = filter_string + strlen(filter_string);
if(ports[1] == 0) // there is only one existing port
sprintf(str_ptr, " and not dst port %hu", ports[i]);
else { // two or more existing ports
sprintf(str_ptr, " and not (dst port %hu", ports[i++]);
while(ports[i] != 0) {
str_ptr = filter_string + strlen(filter_string);
sprintf(str_ptr, " or dst port %hu", ports[i++]);
}
strcat(filter_string, ")");
}
}
printf("DEBUG: filter string is \'%s\'\n", filter_string);
if(pcap_compile(pcap_hdl, &filter, filter_string, 0, 0) == -1)
fatal("pcap_compile failed");
if(pcap_setfilter(pcap_hdl, &filter) == -1)
fatal("pcap_setfilter failed");
}
void caught_packet(u_char *user_args, const struct pcap_pkthdr *cap_header, const u_char *packet) {
u_char *pkt_data;
struct libnet_ip_hdr *IPhdr;
struct libnet_tcp_hdr *TCPhdr;
struct data_pass *passed;
int bcount;
passed = (struct data_pass *) user_args; // pass data using a pointer to a struct
IPhdr = (struct libnet_ip_hdr *) (packet + LIBNET_ETH_H);
TCPhdr = (struct libnet_tcp_hdr *) (packet + LIBNET_ETH_H + LIBNET_TCP_H);
libnet_build_ip(LIBNET_TCP_H, // size of the packet sans IP header
IPTOS_LOWDELAY, // IP tos
libnet_get_prand(LIBNET_PRu16), // IP ID (randomized)
0, // frag stuff
libnet_get_prand(LIBNET_PR8), // TTL (randomized)
IPPROTO_TCP, // transport protocol
*((u_long *)&(IPhdr->ip_dst)), // source IP (pretend we are dst)
*((u_long *)&(IPhdr->ip_src)), // destination IP (send back to src)
NULL, // payload (none)
0, // payload length
passed->packet); // packet header memory
libnet_build_tcp(htons(TCPhdr->th_dport),// source TCP port (pretend we are dst)
htons(TCPhdr->th_sport), // destination TCP port (send back to src)
htonl(TCPhdr->th_ack), // sequence number (use previous ack)
htonl((TCPhdr->th_seq) + 1), // acknowledgement number (SYN's seq # + 1)
TH_SYN | TH_ACK, // control flags (RST flag set only)
libnet_get_prand(LIBNET_PRu16), // window size (randomized)
0, // urgent pointer
NULL, // payload (none)
0, // payload length
(passed->packet) + LIBNET_IP_H);// packet header memory
if (libnet_do_checksum(passed->packet, IPPROTO_TCP, LIBNET_TCP_H) == -1)
libnet_error(LIBNET_ERR_FATAL, "can't compute checksum\n");
bcount = libnet_write_ip(passed->libnet_handle, passed->packet, LIBNET_IP_H+LIBNET_TCP_H);
if (bcount < LIBNET_IP_H + LIBNET_TCP_H)
libnet_error(LIBNET_ERR_WARNING, "Warning: Incomplete packet written.");
printf("bing!\n");
}
|
|