![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
This is a low-level network debugging utility that utilizes raw packet i/o to construct and deconstruct tcp, udp, ipv4, arp, and icmp packets over ethernet.
Diff: scanner.h
- Revision:
- 5:c56386b9fc33
- Parent:
- 4:88fc7fa58931
- Child:
- 6:66c4cd9073aa
diff -r 88fc7fa58931 -r c56386b9fc33 scanner.h --- a/scanner.h Tue Oct 12 06:21:05 2010 +0000 +++ b/scanner.h Tue Oct 12 06:37:21 2010 +0000 @@ -31,12 +31,14 @@ LocalFileSystem local; public: + /// Constructor inline Scanner(Sniffer *_sniffer) : sniffer(_sniffer), local("local") { sniffer->attach_tcp(this, &Scanner::handle_tcp); } + /// Handle incoming TCP packets inline void handle_tcp(TCP_SegmentHeader *packet, u32 data_bytes) { if (packet->syn && packet->ack) @@ -45,6 +47,7 @@ } } + /// Handle the conclusion of the port scan (should not be called externally) inline void finish() { FILE *fp = fopen("/local/PortScan.txt", "w"); @@ -63,6 +66,7 @@ main_log.printf("Port scan complete."); } + /// Start a TCP port scan inline void start(Ethernet_MAC src, Ethernet_MAC dst, IP_Address srcip, IP_Address dstip) { // Create the ethernet frame, IP packet, and TCP segment memory mapping @@ -107,8 +111,10 @@ //scan(); } + /// Incremental scan updates (should not be called externally) inline void scan() { + // Common ports... currently unused static u16 ports[] = {1, 2, 3, 5, 7, 9, 11, 13, 17, 18, 19, 20, 21, 22, 23, 24, 25, 35, 37, 39, 41, 42, 43, 47, 49, 50, 51, 52, 53, 54, 56, 58, 70, 79, 80, 83, 88, 90, 101, 102, 104, 105, 107, 108, 109, 110, 111, 113, 113, 115, 117, 118, 119, 135, 137, 138, 139, 143, 152, 153,