26.07.2018 Views

hacking-the-art-of-exploitation

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

23/tcp open telnet<br />

24/tcp open priv-mail<br />

25/tcp open smtp<br />

[ output trimmed ]<br />

32780/tcp open<br />

32786/tcp open<br />

32787/tcp open<br />

43188/tcp open<br />

44442/tcp open<br />

44443/tcp open<br />

47557/tcp open<br />

49400/tcp open<br />

54320/tcp open<br />

61439/tcp open<br />

61440/tcp open<br />

61441/tcp open<br />

65301/tcp open<br />

sometimes-rpc23<br />

sometimes-rpc25<br />

sometimes-rpc27<br />

reachout<br />

coldfusion-auth<br />

coldfusion-auth<br />

dbbrowse<br />

compaqdiag<br />

bo2k<br />

netprowler-manager<br />

netprowler-manager2<br />

netprowler-sensor<br />

pcanywhere<br />

Nmap run completed -- 1 IP address (1 host up) scanned in 37 seconds<br />

matrix@euclid:~ $<br />

The only service that is actually running is ssh on port 22, but it is hidden<br />

in a sea <strong>of</strong> false positives. A dedicated attacker could simply telnet to every<br />

port to check <strong>the</strong> banners, but this technique could easily be expanded to<br />

spo<strong>of</strong> banners also.<br />

0x480<br />

Reach Out and Hack Someone<br />

Network programming tends to move many chunks <strong>of</strong> memory around and is<br />

heavy in typecasting. You’ve seen for yourself how crazy some <strong>of</strong> <strong>the</strong> typecasts<br />

can get. Mistakes thrive in this type <strong>of</strong> chaos. And since many network programs<br />

need to run as root, <strong>the</strong>se little mistakes can become critical vulnerabilities.<br />

One such vulnerability exists in <strong>the</strong> code from this chapter. Did you<br />

notice it?<br />

From <strong>hacking</strong>-network.h<br />

/* This function accepts a socket FD and a ptr to a destination<br />

* buffer. It will receive from <strong>the</strong> socket until <strong>the</strong> EOL byte<br />

* sequence in seen. The EOL bytes are read from <strong>the</strong> socket, but<br />

* <strong>the</strong> destination buffer is terminated before <strong>the</strong>se bytes.<br />

* Returns <strong>the</strong> size <strong>of</strong> <strong>the</strong> read line (without EOL bytes).<br />

*/<br />

int recv_line(int sockfd, unsigned char *dest_buffer) {<br />

#define EOL "\r\n" // End-<strong>of</strong>-line byte sequence<br />

#define EOL_SIZE 2<br />

unsigned char *ptr;<br />

int eol_matched = 0;<br />

ptr = dest_buffer;<br />

272 0x400

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!