Scan 31
Write-Up By: Ryan C. Barnett This month's challenge is to analyze web server
log files looking for signs of abuse. The Honeypots: Monitoring and
Forensics Project deployed an Apache web server that was configured as an
Open Proxy. Your job is to analyze the log files and identify/classify the
different attacks (trust me, there are a surprising number of them :). All
entries are due Friday, 30 April. Results will be released Friday, 7 May.
Find the rules and suggestions for submissions at the SotM Home Page. Skill Level: Intermediate |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The Challenge: a. Honeynet Web Server Proxy IP sanitized to: 192.168.1.103 Download the Image (25 MB) Initial Steps 1. Download the apache_logs.tar.gz file onto my Redhat Linux host 2. Checked the MD5 has of the file to verify successful file integrity
3. Gunzip and untar the archive
4. CD into the logs directory and get a directory listing so that I would have an idea of the log file sizes I would be dealing with
Questions 1.
How do you think the attackers found the honeyproxy? Answer: Most likely, the “real” people who
were using the honeyproxy (as a proxy) and not a direct attack by worms and
such, found the honeyproxy by using a list from an Open Proxy List Website. Details: Keep in mind that, as with any
honeypot/net deployment, there is some trial and error involved (but hey,
that is why we are doing this – to learn).
When I first deployed the honeyproxy with the configuration outlined
in the Open Proxy Honeypot paper above, I monitored it for a few days. There wasn’t too much traffic except that
of our familiar old friends CodeRed, NIMDA, etc… With a small set in data to analyze, I was able to update the
configurations with some advancements.
One of the configuration changes was to implement an additional HTTP
response header to warn the users of monitoring (Warning: Subject To
Monitoring). In order to verify these
headers and check the proxy anonymity, I decided to use some of the proxy
checking applications on some web sites - http://www.google.com/search?hl=en&ie=UTF-8&oe=UTF-8&q=proxy+check. What is interesting is that while almost
all of these sites offer tools so a security conscience client can check
their own proxy to verify that it is secured correctly, they will always add
an open proxy that is finds to a public list. Here is a perfect example: ·
Proxy Checking Tool – http://www.checker.freeproxy.ru/checker/ ·
Open Proxy List at the same website - http://www.checker.freeproxy.ru/checker/last_checked_proxies.php It didn’t take long for the honeyproxy’s IP
to propagate to other proxy lists and all of a sudden the traffic spiked
significantly. It was at this point
that I knew I was ready to officially deploy the honeyproxy for the SoTM
Challenge. The official start time
was Tue Mar 9 22:02:41 2004
(according to the first line in the error_log). If you compare this to the first log entry in the access_log
file (09/Mar/2004:22:03:09 –0500) you will see that the first client request
came only 28 seconds after the honeyproxy started up. Without the background information
outlined above, it would seem odd to receive actual proxy requests this fast. 2.
What different types of attacks can you identify? For each
category, provide just one log example and detail as much info about the
attack as possible (such as CERT/CVE/Anti-Virus id numbers). How many can you
find? Answer: One of the main benefits of
honeypots/nets is that your logging should only capture malicious activity,
reducing the amount of data to analyze.
While this is the case, comparatively speaking to normal production
NIDS deployments, this does not necessarily mean that the data sets will be
“small”. The honeyproxy gathered ~
295 MB of data in the log files. This
is not a small amount of data if you are manually reviewing the logs. Anytime you have a large data set, you
must develop an method to parse/analyze the logs looking for signs of
attack/abuse/malicious intent. So,
before we can answer “What” attacks are present in the various Open Proxy
Honeypot logs, we need to figure out “How” we are going to identify these attacks. Even though, technically, all of the log
data captured by the proxypot is suspect by nature, our methods should still
be applicable to normal web server log file analysis. Below are the different ways in which I
identified and quantified the various attacks: Search Logs For Mod_Security-Message: When Mod_Security
identifies a problem with a request due to a security violation, it will do
two things – 1) Add in some additional client request headers stating why
mod_security is taking action, and 2) Log this data to the audit_log and
error_log files. These error messages
can be triggered by Mod_Security special checks such as the
SecFilterCheckURLEncoding directive, basic filters such as “\.\.” to prevent
directory traversals and advanced filters based on converted snort rules. Search Logic: Show
me all of the audit_log entries that have the mod_security-message header,
then sort the results, then only show me unique entries with a total count of
each type in reverse order from highest to lowest, then remove the
mod_security-message data at the beginning of each line and list the results
with the less command.
Search Command: The
command string below will accomplish the search logic from above.
By looking at the bolded entries listed above, it appears that there are a large number Brute Force Attempts (Basic Authentication Headers and Password Credentials submitted in the URL field and POST_PAYLOAD). Utilization of the AllowCONNECT Proxying Capabilities: Our set-up of the
proxypot allowed proxying to a wide variety of ports/protocols that are
targeted by attackers. These include
ports 25 (SMTP) and 6667/6666 (IRC).
Since these connection attempts will not trigger Mod_Security, we can
not use the same search technique above to gather statistics. We will need to filter our search on HTTP
requests that use these specific port numbers. Search Logic: Search the access_log
file for all CONNECT requests, filter the output to only display the URL portion,
only show unique entries and then sort in reverse order from highest to
lowest and display with less. Search Command: The command string
below accomplishes the search logic from above.
The bolded entries listed above show clients using the CONNECT method to have our proxypot connect to other systems on port 25 (SMTP). This is a sure sign of SPAMMERS. Search Logs For Abnormal HTTP Status Codes: The Mod_Security
default action settings were to generate a “200” status code for identified
attacks. This action was to “trick”
malicious proxypot users into thinking that their attack were successful. This means that this means that we cannot
solely rely on status codes of “200 OK” to indicate that everything is
normal. With this in mind, we can
still analyze any status codes that were not “200 OK” and assess the results. Search Logic: Search the audit_log
file for all of the HTTP Response Codes returned by our proxypot, then remove
all HTTP version info, next only show unique entries in reverse order. Search Command: The command strings
below accomplishes the search logic from above.
Generally speaking, any HTTP Status Code in the 4XX-5XX ranges should be investigated (bolded above). Additionally, there are a few status codes that are abnormal – (null) which is caused by CONNECT Method requests and others which hare mis-spelled – “Moved Perminantly”. HTTP Request Methods: Many web-based
attacks will use standard request methods such as GET, HEAD and POST. There are many attacks, however, that use
other request methods such as TRACE, SEARCH and DELETE. By analyzing these request methods, it may
be possible to identify different attacks. Search Logic: Search the access_log
file for all entries, then only display the HTTP Request Method portions,
next only show unique entries and then sort in reverse order from highest to
lowest. Search Command: The command strings
below accomplishes the search logic from above.
These HTTP Request Methods indicate that a few things: 1) That of the normal methods (GET, HEAD and POST) there were a large number of HEAD requests indicating Brute Force attempts, and 2) There are a large number of non-valid request methods. Each of these abnormal request methods should be investigated. Non-HTTP Compliant Requests: HTTP Requests that
are compliant with the protocol should have the following composition –
<Request Method> <Universal Resource Identifier> <Protocol
Version> <Linefeed/Return>.
Example: Get /index.html HTTP/1.0.
When attackers are probing and exploiting
vulnerable servers/applications, they often send requests that deviate from
the proper HTTP Request format to accomplish the exploit or nudge the app
into revealing desired information such as error text, etc… Search Logic: Search the audit_log
file for all “Error:” entries, then do not display entries that are not HTTP
RFC applicable, next sort and only show unique entries with less. Search Command: The command strings
below accomplishes the search logic from above.
The bolded entries above have identified problems when clients do not adhere to the RFC standard. All of these entries should be reviewed to determine what caused these error messages. Armed with these different analysis categories, I analyzed the log files with standard *nix text utilities such as grep, awk and sed searching for specific signs of abuse. 2.1 Attack Category- SPAMMERS: The large majority of users of the proxypot were SPAMMERS trying to send their email through our server to hide their true location and make it hard to track down the emails origin. Number of Log Entries: 23562 Search Logic: Search the audit_log file for all requests for well-known CGI email programs and CONNECT requests to a host on port 25. Search Command: grep Request audit_log | egrep -i 'formmail|sendmsg.cgi|mail|\:25 HTTP' | less Example Entry: In the audit_log entry below, the client is attempting to send email through our proxy onto the www.centrum.is host and send an email through the FormMail.pl CGI script. Luckily, Mod_Security intercepted this request due to URL Encoding problems in the body of the email, and thus it was never forwarded on to the destination host.
When email is sent through a web server CGI script like this, the SMTP MIME headers will not include any data prior to leaving this host. This means that normal SMTP trace-back techniques will not lead to the 67.83.151.132 host unless web logs are correlated. CVE Info: http://www.securityfocus.com/bid/3955/info/ or http://icat.nist.gov/icat.cfm?cvename=CAN-2001-0357 2.2
Attack Category- Brute Force Authentication Attacks: There
were a very large number of attacks against password protected content. There were three different type of
authentication being targeted by attackers, GET (with Username/Password in
the URL field), POST (with user credentials in the post payload) and HEAD
(with Basic Authentication Header added).
We will discuss Brute Force Attacks later in question 5. 2.3 Attack Category- Vulnerability Scans: There were two different vulnerability scans identified in the log files. One was conducted using the Nessus (http://www.nessus.org) tool and another using Void (http://www.packetstormsecurity.org/UNIX/cgi-scanners/exp.dat). Nessus Scan Number of Log Entries: 10296 Search Logic: Search the access_log file for all entries with the word Nessus in them and show with the less command. Search Command: grep Nessus access_log | less Example Entry: The example entries below show that a Nessus vulnerability scan was conducted against our proxypot on March 12th at 10:30 pm. You can easily identify this as a Nessus scan due to the User-Agent field data.
Some interesting info on this scan: · The client IP address of the scan is from a website called – http://port-scan.de. Interestingly, this site will allow you to run port scans, vulnerability scans, etc… against a site and it will email you the results. Supposedly, you can only run it against your own IP address, however the client IP address can be easily spoofed in the data sent to the http://www.port-scan.de/cgi-bin/portscan.cgi script. · Even though we were leveraging the Snort web-attack files, Nessus has such as large number of attacks that it checks for that we would have missed a bunch of these requests since we did not have a signature in the snortmodsec-rules.txt file. You can see which requests we missed when the proxypot issues a “404” status code. If we had a corresponding signature, the proxypot would have issued a “200”. · I decided to take the same approach that we have done with converting the Snort rules into mod_security rules with the nessus web entries. I extracted all of the entries for the Nessus vulnerability scan, used awk and sed to get the URL Request info and format it appropriately and then used the snort2modsec.pl script to create new nessus/mod_security filters. Below are some example of the converted rules:
The full nessusmodsec-rules.txt file that I created can be downloaded here – http://honeypots.sourceforge.net/nessusmodsec-rules.txt. Void Scan Number of Log Entries: 407 Search Logic: Search the access_log file for all entries with the word “by void” in them (ignoring case) and show with the less command. Search Command: grep -i "By Void" access_log |
less Example Entry: The example entries below show that a Void vulnerability scan was conducted on March 13th at 2:34 pm. You can easily identify this as a Void scan due to the data appended to the URL request. This scan was different than the Nessus scan because it was not conducted against our proxypot, but rather through our proxy to other web sites. This was a distributed scan against a number of port web sites. Example data is below.
You can download the Void scan request file from Packetstorm - http://www.packetstormsecurity.org/UNIX/cgi-scanners/exp.dat. Some interesting info on this scan: · The client IP address of the scan resolves to c-24-127-175-68.we.client2.attbi.com, which seems to be a home user on the Comcast Cable network in California. · After searching the access_log and audit_log for this IP address, it appears that this server is a proxy server as well. How did I determine this? Well, we will talk about identifying proxy uses in a later section, however that will deal with inspecting additional HTTP Request Headers. I identified this architecture by the unusually high number of different User-Agents from this IP address. I searched the audit_log for requests from this IP and then extracted the User-Agents. Below is a list of some of the User-Agents Identified:
If this were a single user, there would not be this much variation in the User-Agent fields. 2.4 Attack Category- Web-Based Worms: There were three different type of web worms identified in the log files. ·
CodeRed - The "Code Red" worm is malicious
self-propagating code that exploits Microsoft Internet Information Server
(IIS)-enabled systems susceptible to the vulnerability described in CA-2001-13 Buffer
Overflow In IIS Indexing Service DLL. Its activity on a compromised
machine is time senstive; different activity occurs based on the date (day of
the month) of the system clock. http://www.cert.org/advisories/CA-2001-23.html.
Number of CodeRed Log Entries: 47 from the following hosts:
Search Logic: Search the access_log file for all entries with the word “default.ida” in them and show with the less command. Search Command: grep default.ida access_log | less Example Entry: The example entries below show some CodeRed requests.
· NIMDA – this worm spread through a number of vectors with the following two being relevant for our proxypot a.
Spread from client to web server via active scanning
for and exploitation of various Microsoft IIS 4.0 / 5.0 directory traversal
vulnerabilities (VU#111677 and CA-2001-12) b.
Spread
from client to web server via scanning for the back doors left behind by the
"Code Red II" (IN-2001-09),
and "sadmind/IIS" (CA-2001-11) worms Number of NIMDA Log Entries: 3536 from the following hosts:
Search Logic: Search the access_log file for all entries with the word “cmd.exe or root.exe” in them except if the word Mozilla is in the entry (indicating non-worm requests such as from the Nessus scan) and show with the less command. Search Command: egrep 'cmd.exe|root.exe' access_log | grep –v Mozilla | less Example Entry: The example entries below show some NIMDA requests.
One thing that is interesting about these requests is that if the initial request for the cmd.exe file returns a status code of “200”, then it will move onto the second phase and try to use tftp to copy the worm code over to the vulnerable IIS server (bolded above). This propagation mechanism means that this is the “E” version of the NIMDA worm - http://www.dshield.org/pipermail/intrusions/2001-October/002063.php. · Welchia- http://securityresponse.symantec.com/avcenter/venc/data/w32.welchia.b.worm.html. Welchia attempts to exploit the WebDav vulnerability (described in Microsoft Security Bulletin MS03-007) using TCP port 80. Number of Welchia Log Entries: 10 from the following hosts:
Search Logic: Search the access_log file for all entries with the regular expression text of “SEARCH any two characters then x90” in them and show with the less command. Search Command: egrep "SEARCH
..x90" access_log |
less Example Entry: The example entry below show one Welchia request.
By looking at this entry, you can see that the reason that our Apache proxypot generated an error was that the request URI was too long. 2.5 Attack Category – Banner/Click-Thru Fraud: Due to the large amount of revenue that can be generated by banner ads and pay-per-click hyperlinks, they are ripe targets for the greedy. This is not a normal “web-attack” like we have discussed thus far. There are no IDS attack signatures to identify. Each individual request, in and of itself, is not malicious. The abuse becomes visible when partner web sites inspect the source IP addresses/referrer of the banner ad entries. If the same IP address is repeated too many times within a time period, then this would indicate that an automated program was utilized instead of by real people. Number of Banner Fraud Log Entries: 3311 from 227 different hosts. Search Logic: Search the access_log file for all entries with the term “click” in them and show with the less command. Search Command: grep -i click access_log | less Example Entry: The example entries below show some banner ad fraud requests from the same IP address.
2.6 Attack Category- IRC Connections: In the wild west of Internet Relay Chat (IRC), hiding your real IP address is a smart move if you want to avoid being hit with denial of service attack. There are groups/individuals who are constantly playing “King of the Hill” for the coveted role is SysOp on a particular channel. If a mutiny is successful and the SysOp is knocked off the channel, then the position is up for grabs. The SysOp needs to maintain control of the channel by having one of their bots logged in at all times. This is where our proxypot comes into play. If a bot logs into a channel through our proxypot, then our proxypot becomes the target of any DoS attacks and not the real source IP. Number of IRC Connection Log Entries: 1696 from 239 different hosts. Search Logic: Search the access_log file for all entries to common IRC ports and show with the less command. Search Command: egrep '\:666[678] HTTP' access_log | less Example Entry: The example entries below show some example IRC connection attempts.
3.
Do attackers target Secure Socket Layer (SSL) enabled web
servers as their targets? Answer: Yes, attacker do target SSL enabled
web servers. Number of SSL connections: 11778 from 152
different hosts. Search Logic: Search the access_log file for all entries with “https” or port “:443” in the target URL and show with the less command. Search Command: egrep
'https\:|\:443 HTTP' access_log | less Example Entry: The example entries below show some example SSL connection attempts.
Did they target SSL on our honeyproxy? Answer: Yes, attackers did try and access the
SSL web server on our proxypot. Number of SSL connections: 2313 from 4
different hosts. Search Logic: Search the ssl-access_log file for all entries with the less command. Search Command: less ssl-access_log Example Entry: The example entries below show some example SSL connection attempts against our proxypot.
Why would they want to use SSL? Answer: There are two different answers for
this question – ·
SSL software is just like any other application and
vulnerabilities may surface. When
they do, an attacker may probe the SSL-enabled web server for its version
information to confirm a vulnerable implementation. ·
Network Intrusion Detection Systems (NIDS) will not be able to
inspect the Layer 7 (Application) data in the HTTPS requests. Attackers will often target an SSL-enabled
web server to try and hide their activities from NIDS sensors. Why didn't they use SSL exclusively? Answer: Once again, there are two main answers
here – ·
Not every target web server offered SSL service. ·
As mentioned above, attackers want to hide their web attacks
from NIDS by tunneling it through SSL connections. This becomes even more obvious if the attacker were connecting
directly to the target web server from their real system. In the case of our proxypot, however, the
attacker has already taken steps to obfuscate their IP address so there are
less concerned with being stealthy since they have anonymity. 4.
Are there any indications of attackers chaining through other
proxy servers? Describe how you identified this activity. List the other
proxy servers identified. Can you confirm that these are indeed proxy
servers? Answer: Yes, there is evidence of proxy
chaining by clients. The main
evidence which indicates proxy use is the inclusion of the “Via” and
“X-Forwarded-For” headers in the requests and responses. Number of Proxy Connections: 19271 requests from
304 different hosts serving as a proxy for 5951 clients. Search Logic: · Number of proxied requests sent to our server – Search the audit_log file for all X-Forwarded-For entries, then give me a total number of requests. · Number of proxy servers connecting to our proxy – Search the audit_log file for all Requests and X-Forwarded-For entries, then extract all X-Forwarded-For entries with their preceding/corresponding request, then extract the client IP from the request and sort it and give me a total number of unique hosts. · Number of clients who used a proxy to connect to our proxy - Search the audit_log file for all X-Forwarded-For entries, then extract only the IP addresses specified in this token and sort it and give me a total number of unique hosts. Search Command: ·
Number of proxied requests sent to our server
– egrep 'X-Forwarded-For\: '
audit_log | wc -l ·
Number of proxy servers connecting to our proxy
– egrep 'Request\: |X-Forwarded-For\:
' audit_log | egrep -B1 'X-Forwarded-For' | egrep 'Request\: ' | awk '{print
$2}' | sort | uniq | wc -l ·
Number of clients who used a proxy to connect to
our proxy - egrep
'X-Forwarded-For\: ' audit_log | awk '{print $2}' | sort | uniq | wc -l List of Proxy Servers: The proxy servers identified are in this list – proxy_servers.txt Confirming the Proxy Servers: In order to confirm that these IP addresses were in fact proxy servers themselves, we could take three different approaches: · Check Well-Known Proxy Lists: We can check online open proxy lists for these IP address as places such as the Distributed Server Boycott List website - http://dsbl.org/main. · Use an Online Proxy Checker: We can use one of the proxy checking web sites (discussed in question 1) to verify if each IP address is in fact a proxy server. · Make a Request Through the Server: We can make a direct connection to the server in question and make a proxy request and see what comes back. Below is an example of this:
While the X-Forwarded-For and Via headers do indicate the use of proxy servers, they do not necessarily equal malicious intent. The Via header is used to identify proxy servers, per RFC 2068 http://www.cse.ohio-state.edu/cgi-bin/rfc/rfc2068.html#sec-14.44. The Via general-header field MUST
be used by gateways and proxies to indicate the intermediate protocols and
recipients between the user agent and the server on requests, and between the
origin server and the client on responses. It is analogous to the
"Received" field of RFC 822 and
is intended to be used for tracking message forwards, avoiding request loops,
and identifying the protocol capabilities of all senders along the
request/response chain. As you can see from the RFC, all proxy servers MUST add in the “Via” header for requests that they service. By looking at the audit_log data, we can identify the path that these requests have taken to reach their target web server and identify intermediary proxy servers.
There is some great information (with a graphic) for TRACE
Request communication (with Via headers) from the Oreilly Open Book – Web
Client Programming with PERL web site - http://www.oreilly.com/openbook/webclient/ch03.html#34866.
The X-Forwarded-For client request header shows the client IP address that made the request to the proxy server that connected to our proxypot. Two caveats here for IP trace-back of this connection: ·
This header can be easily spoofed. The IP address connecting to our proxypot can in fact be the
one making all of the connection and is spoofing X-Forwarded-For headers to
cause confusion or shift blame. ·
The IP address listed in the X-Forwarded-For header may in fact
me another proxy server. This is
known as chaining proxy servers/requests, which leads to our next topic. As discussed above, the existence of the X-Forwarded-For and Via
headers does not directly indicate malicious intent, however there is another
indicator of “intended” proxy chaining – the User-Agent field with term
ProxyChains. ProxyChains is a command
line tool used to tunnel connections through specific proxy servers - http://proxychains.sourceforge.net/. If a client makes a request to our proxy
server with a User-Agent field of “ProxyChains”, then this indicates intent
to force connections through certain hosts. Example Entry: The example entries below show some example connection attempts with the ProxyChains info.
This first entry shows a client trying to use ProxyChains to have our system connect to the SMTP service on another host. The second entry shows a client trying to use ProxyChains to have our system connect to another web server. The final indication of proxy chaining would be the use of Socks/Wingate client checkers. These applications send SOCKS requests to proxy servers and the web server log file shows this data as the request “\x04\x01”. Look familiar? We already identified these entries in our “Request Method” analysis section above. Here are some example entries from our proxypot’s access_log file for these types of connections:
Here is more information from a mail-list
where a user has seen same these connection attempts - http://cert.uni-stuttgart.de/archive/suse/security/2004/02/msg00402.html.
5.
Identify the different Brute Force Authentication attack
methods. Can you obtain the clear text username/password credentials?
Describe your methods. Answer: There were three different types of
Brute Force Authentication attacks launched through our proxypot. ·
HTTP GET Requests – This form of authentication includes
passing the username/password credentials as part of the URL requested with
an HTTP GET request. An example entry
is below where a client is trying to authenticate to Yahoo accounts:
By analyzing the distribution of the target web servers and the user credentials, it seems that the attacker is distributing his attack across multiple Yahoo servers and is targeting mutations of the account “exodus” with a few passwords. Perhaps this combination will result in less chances of being identified by locking out accounts. Generally speaking, this form of authentication is insecure since the data is not sent over SSL and that these URLs may be cached locally on systems, thus exposing user credentials. ·
HTTP POST Requests – This form of authentication includes
passing the username/password credentials as part of the PAYLOAD of an HTTP
POST request. An example entry is
below where a client is trying to authenticate to Yahoo accounts:
As you can see from the audit_log entry above, this client is try to submit authentication credentials to the target web site. Mode_Security identified the authentication keyword of “password\=” and subsequently blocked the request. ·
HTTP Basic Authentication – With Basic Authentication, the web
server prompts the client’s browser for credentials with a “401” status
code. When the web browser receives
the initial 401 – it displays the familiar login pop-up box: When the client clicks “OK” the same URL is requested with an HTTP GET Method, however this time it includes an additional client header: Authorization: Basic XXXXXXXXXXXXX. The data in the Authorization header is the Base64 MIME Encoded user credentials submitted in the form of “username:password”. Below is an example basic authentication attempt:
The example entry above seems to be a real person trying to authenticate to the web site. How can I tell that this is a real person and not an automated script? Two indicators: o
The request has a seemingly valid User-Agent field which
indicates that the client is using Netscape-Navigator on a Windows 98
system. This data can be spoofed of
course, so we need supplemental data to support our theory of a real person
making this request. o
The request uses the GET Methods. When attackers conduct Brute Force attack sessions, they often
use the HEAD request since it is faster due to not needed to transmit any
body data. The attacker can determine
if the Authorization data is valid based on the HTTP Status code
returned. If the server responds with
a “200 OK”, then they have valid credentials. Luckily, as a preventative measure, our proxypot has been configure to identify any requests that submit an “Authorization: Basic” header, block the request and respond with a status code of “200”. This has two benefits – 1) the requests are never sent to the target web site, thus protecting them from the attack, and 2) The results of the Brute Force attack session are useless since it appears that all credentials are valid. Obtaining the Cleartext Authorization Credentials: As discussed above, the only form of authentication that is obfuscating the credentials is Basic Authentication. Fortunately/Unfortunately, depending on your view, basic authentication is trivial to decode. First, we must extract all of the basic auth headers:
Next, we can use the MIME::base64 PERL module to decode
this data:
6.
What does the Mod_Security error message "Invalid Character
Detected" mean? What were the attackers trying to accomplish? Answer: Mod_Security will generate this error
message based on three different security filters/checks: ·
SecFilterCheckURLEncoding – URL Encoding
validation Special characters need to be encoded before
they can be transmitted in the URL. Any character can be replaced using the
three character combination %XY, where XY is an hexadecimal character code
(see http://www.rfc-ditor.org/rfc/rfc1738.txt for more details).
Hexadecimal numbers only allow letters A to F, but attackers sometimes use
other letters in order to trick the decoding algorithm. Mod_security checks
all supplied encodings in order to verify they are valid. ·
SecFilterCheckUnicodeEncoding – Unicode encoding validation Unicode encoding validation first appeared in version
1.6. Normally, it is disabled by default. You should turn it on if your
application or the underlying operating system accept/understand Unicode.
This feature will assume UTF-8 encoding and check for three types of errors: o
Not enough bytes. UTF-8
supports two, three, four, five, and six byte encodings. ModSecurity will
locate cases when a byte or more is missing. o
Invalid encoding. The two
most significant bits in most characters are supposed to be fixed to 0x80.
Attackers can use this to subvert Unicode decoders. o
Overlong characters. ASCII
characters are mapped directly into the Unicode space and are thus
represented with a single byte. However, most ASCII characters can also be
encoded with two, three, four, five, and six characters thus tricking the
decoder into thinking that the character is something else (and, presumably,
avoiding the security check). ·
SecFilterForceByteRange - Byte range check You can force requests to consist only of bytes from a
certain byte range. This can be useful to avoid stack overflow attacks (since
they usually contain "random" binary content). To only allow bytes from 32 to 126
(inclusive), use the following directive: SecFilterForceByteRange 32
126 Default range values are 0
and 255, i.e. all byte values are allowed. The following diagram shows a portion of the ASCII Chart which list each of the entries from 0 – 143:
The full ASCII chart is located here - http://i-technica.com/whitestuff/asciichart.html.
When these three encoding checks are combined, they are able to
identify a large number of attacks/problems.
Below are a few examples: SOCKS Proxy Scan: This is the same request as discussed above
in the proxy section. Notice that the
mod_security audit_log decodes the “\x04\x04” data into its “^D^A” form.
CodeRed/NIMDA Worm Attacks: Both of these worms used abnormal
encoding to execute their attacks.
CodeRed used binary encoding and NIMDA used double-unicode
encoding. Below are two examples:
In both cases, the worms were trying to
trick the URL decoding mechanisms on the web server in order to get it to
execute some code. 7.
Several attackers tried to send SPAM by accessing the following
URL - http://mail.sina.com.cn/cgi-bin/sendmsg.cgi. They tried to send email
with an html attachment (files listed in the /upload directory). What does
the SPAM webpage say? Who are the SPAM recipients? Answer: The html web pages that were captured
in the “/upload” directory are written in Chinese. In order to read the html file, I decided to upload the file to
my own honeypot web site - http://honeypots.sourceforge.net/20040313-174514-68.41.205.235-GoodMornding.htm. I then used an online web translator to
translate the Chinese into English. A
portion of the web page is shown below:
SPAM Recipients: By reviewing the audit_log data for these
POST requests, we can identify the targeted SPAM recipients by inspecting the
MIME header data in the file upload data:
The bolded section above entitled –
name=”cc”, lists the recipients of this SPAM email. 8.
Provide some high level statistics on attackers such as: Top Ten Attacker IP Addresses – cat
access_log | awk '{print $1}' | sort | uniq -c | sort -rn | head –10 Example Requests for each IP - for
f in `cat access_log | awk '{print $1}' | sort | uniq -c | sort -rn | head
-10 | awk '{print $2}'`; do grep $f access_log | head –1 ; done
Top Ten Targets: Command used - cat
access_log | awk '{print $7}' | sort | uniq -c | sort -rn | head –10
Top User-Agents (Any weird/fake agent strings?): Interesting/weird entries –
Attacker correlation from DShield and other sources? If Dshield has data in
the “Total Records against IP” field, then this client has been up to not
good since other people have reported the IP due to abuse. Two out of the Top Ten Attackers were
listed in Dshield – · 195.16.40.200 - http://www.dshield.org/ipinfo.php?ip=195.16.40.200&Submit=Submit
· 61.144.119.66 - http://www.dshield.org/ipinfo.php?ip=61.144.119.66&Submit=Submit
Bonus Question: Why do you think the attackers were targeting
pornography websites for brute force attacks? (Besides the obvious physical
gratification scenarios :) Answer: There are a number of
reasons why attackers target Porn sites: Credit Card Data: Porn sites use credit
cards for payment and age verification.
This data makes these site a ripe target. User Credentials As Currency: Once user credentials have been verified as valid, they then have value. Attackers can then used these credentials as currency to barter and trade with others. How do I know this? I noticed that many of the same clients who were conducting brute force attacks against port sites, were also using the HTTP CONNECT Method to join IRC channels.
Brute Force Attack –
IRC Connection –
I decided to monitor the IRC communication
going through the proxypot by running tcpdump in binary capture mode and then
used Honeynet Project’s Privmsg.pl script - http://www.honeynet.org/tools/danalysis/privmsg
- to extract the data. The attackers
joined a channel called, appropriately enough, #xxxpasswords. ·
They were trading the porn site credentials like baseball cards ·
Below are excerpts from the IRC log file:
In the xxxpasswords channel, the attackers were using automated
channel commands to verify the credentials they submit ·
??PassCount ·
??level ·
??spoofer ·
??post ·
??multinet ·
??crossposting These commands will run a bot program to submit username/password info to the specified web site in order to verify the credentials. Below are some excerpts from the IRC log file -
The last bolded entry shows that there is a
“Freebie site” and it provides the authentication credentials – username =
xona09 and password = secure09. Below
is the corresponding proxypot audit_log entry when the IRC bot verified these
credentials:
Even though the proxypot's IP/Hostname was obfuscated from the
logs, can you still determine the probable network block owner? Answer: There are two
different possibilities: IP Address in Cookie: In order to try and
protect the IP address of the proxypot in the SoTM logs, I conducted numerous
text anonymization steps using common unix commands such as sed. I wanted to make sure that the proxypot’s
IP address in logs was obfuscated to 192.168.1.103. Well, I should have tried some more “fuzzy logic”
search/replace steps because I missed one cookie that has the proxypot’s IP
address in it J! In the cookie, the “.” separator is URL
Encoded to “%2E”.
Propagation Mechanisms of Worms (Target IP Selection): Nimda and Code Red propagate primarily by targeting IP addresses in similar ranges. Over 75% of the targeted IP addresses are similar to the infected host’s address, and less than 25% are randomly selected. For example, an infected host with an address of 24.128.1.1 will target hosts with addresses of 24.*.*.* and/or 24.128.*.*. The rationale is to distribute the propagation effort among as many hosts as possible and prevent overlapping efforts---this enables the worm to spread quickly throughout the entire Internet. An example NIMDA worm request is below –
We can then
take this IP address and run a WHOIS to verify the Network Block Owner:
Comcast Cable, Inc.
|