26.07.2018 Views

hacking-the-art-of-exploitation

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

0x640<br />

Log Files<br />

One <strong>of</strong> <strong>the</strong> two most obvious signs <strong>of</strong> intrusion is <strong>the</strong> log file. The log file kept<br />

by <strong>the</strong> tinyweb daemon is one <strong>of</strong> <strong>the</strong> first places to look into when troubleshooting<br />

a problem. Even though <strong>the</strong> attacker’s exploits were successful,<br />

<strong>the</strong> log file keeps a painfully obvious record that something is up.<br />

tinywebd Log File<br />

reader@<strong>hacking</strong>:~/booksrc $ sudo cat /var/log/tinywebd.log<br />

07/25/2007 14:55:45> St<strong>art</strong>ing up.<br />

07/25/2007 14:57:00> From 127.0.0.1:38127 "HEAD / HTTP/1.0" 200 OK<br />

07/25/2007 17:49:14> From 127.0.0.1:50201 "GET / HTTP/1.1" 200 OK<br />

07/25/2007 17:49:14> From 127.0.0.1:50202 "GET /image.jpg HTTP/1.1" 200 OK<br />

07/25/2007 17:49:14> From 127.0.0.1:50203 "GET /favicon.ico HTTP/1.1" 404 Not Found<br />

07/25/2007 17:57:21> Shutting down.<br />

08/01/2007 15:43:08> St<strong>art</strong>ing up..<br />

08/01/2007 15:43:41> From 127.0.0.1:45396 "<br />

<br />

<br />

jfX1CRj j jfXCh<br />

fT$ fhzifSj QVC Iy<br />

I?<br />

$$$$$$<br />

Rh//shh/binRS<br />

$$$$$$$$$$$$$$$$$$<br />

$$$$$$$$" NOT HTTP!<br />

reader@<strong>hacking</strong>:~/booksrc $<br />

Of course in this case, after <strong>the</strong> attacker gains a root shell, he can just edit<br />

<strong>the</strong> log file since it’s on <strong>the</strong> same system. On secure networks, however, copies<br />

<strong>of</strong> logs are <strong>of</strong>ten sent to ano<strong>the</strong>r secure server. In extreme cases, logs are sent<br />

to a printer for hard copy, so <strong>the</strong>re is a physical record. These types <strong>of</strong> countermeasures<br />

prevent tampering with <strong>the</strong> logs after successful <strong>exploitation</strong>.<br />

0x641<br />

Blend In with <strong>the</strong> Crowd<br />

Even though <strong>the</strong> log files <strong>the</strong>mselves cannot be changed, occasionally what<br />

gets logged can be. Log files usually contain many valid entries, whereas<br />

exploit attempts stick out like a sore thumb. The tinyweb daemon program<br />

can be tricked into logging a valid-looking entry for an exploit attempt.<br />

Look at <strong>the</strong> source code and see if you can figure out how to do this before<br />

continuing on. The idea is to make <strong>the</strong> log entry look like a valid web request,<br />

like <strong>the</strong> following:<br />

07/22/2007 17:57:00> From 127.0.0.1:38127 "HEAD / HTTP/1.0" 200 OK<br />

07/25/2007 14:49:14> From 127.0.0.1:50201 "GET / HTTP/1.1" 200 OK<br />

07/25/2007 14:49:14> From 127.0.0.1:50202 "GET /image.jpg HTTP/1.1" 200 OK<br />

07/25/2007 14:49:14> From 127.0.0.1:50203 "GET /favicon.ico HTTP/1.1" 404 Not Found<br />

This type <strong>of</strong> camouflage is very effective at large enterprises with extensive<br />

log files, since <strong>the</strong>re are so many valid requests to hide among: It’s easier to<br />

blend in at a crowded mall than an empty street. But how exactly do you hide<br />

a big, ugly exploit buffer in <strong>the</strong> proverbial sheep’s clothing?<br />

334 0x600

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

Saved successfully!

Ooh no, something went wrong!