Trustwave Unveils New Offerings to Maximize Value of Microsoft Security Investments. Learn More

Trustwave Unveils New Offerings to Maximize Value of Microsoft Security Investments. Learn More

Managed Detection & Response

Eliminate active threats with 24/7 threat detection, investigation, and response.

Co-Managed SOC (SIEM)

Maximize your SIEM investment, stop alert fatigue, and enhance your team with hybrid security operations support.

Advisory & Diagnostics

Advance your cybersecurity program and get expert guidance where you need it most.

Penetration Testing

Test your physical locations and IT infrastructure to shore up weaknesses before exploitation.

Database Security

Prevent unauthorized access and exceed compliance requirements.

Email Security

Stop email threats others miss and secure your organization against the #1 ransomware attack vector.

Digital Forensics & Incident Response

Prepare for the inevitable with 24/7 global breach response in-region and available on-site.

Firewall & Technology Management

Mitigate risk of a cyberattack with 24/7 incident and health monitoring and the latest threat intelligence.

Offensive Security
Solutions to maximize your security ROI
Microsoft Exchange Server Attacks
Stay protected against emerging threats
Rapidly Secure New Environments
Security for rapid response situations
Securing the Cloud
Safely navigate and stay protected
Securing the IoT Landscape
Test, monitor and secure network objects
Why Trustwave
About Us
Awards and Accolades
Trustwave SpiderLabs Team
Trustwave Fusion Security Operations Platform
Trustwave Security Colony
Technology Alliance Partners
Key alliances who align and support our ecosystem of security offerings
Trustwave PartnerOne Program
Join forces with Trustwave to protect against the most advance cybersecurity threats
SpiderLabs Blog

Hooked on Packets: Reading PCAPs for D Students - Preview

SOURCE Boston is coming up in April, and Mike Ryan and I are giving a presentation about making packet analysis easier for the masses. One of the challenges with building new protocol parsers for tools such as Ettercap and Wireshark is many of these parsers are written in C. C is very fast and powerful, however you run the risk of introducing vulnerabilities in the software. And, for folks who aren't fluent C programmers, building these parsers can be intimidating.

So, what are we going to do to change this? One of the pieces we've been working on is trying to merge Lua into Ettercap. We did a presentation at Derbycon last year about how we planned to do this, and now we have some practical uses. We're going to take a look at how to build easy to use scripts, similar to the Nmap NSE scripts, to allow manipulation and parsing of data that would otherwise require C code.

I wrote a quick example that we will examine in more detail during our presentation. The example focuses on tracking HTTP traffic on the network or in captures.

Why do we care about HTTP requests? On a penetration test, we may use a MitM attack to target groups of individuals and watch their requests in order to identify interesting targets for session theft or other attacks. Another good example of when this is useful is when looking at malware. We may want to determine what requests malware is making, where it's being redirected to, and even watch for beaconing requests.

It turns out, doing these things with existing tools can be pretty cumbersome. Right now, you could try to match requests and replies in tcp dump. But, if there are multiple simultaneous requests, it gets trickier. You can do the same thing in Wireshark and Tshark, but you have to do a lot of clicking around-- or write some lua tore-assemble the sessions and then track down the data.

Our solution adds a basic registry to Ettercap. So, you can store session data. To create a session we can do something like this:

-- Get session key for tracking req->reply pairs local session_id = http.session_id(p,hobj)

-- We have a session, lets get our registry space local reg = ettercap.reg.create_namespace(session_id)

Now, we have a local registry that is unique to our session.We can use this registry to store session data. One thing we may want to do is extract request data, and store it until the response comes in so we can match them up. To do something like this, we can parse the packet:

-- Parse the packet (p) and retrieve the http data

local hobj = http.parse_http(p)

If we are looking at a request, we want to store the request for retrieval in the registry for when we see the response:

if hobj.request then

reg.request = hobj

If we saw a response, then we just want to print it out:

      -- Get the status code      local code = hobj.status_code      -- Build the request URL      -- If we have a 2XX or 4XX or 5XX code, we won't need to log redirect      -- so just log the request and code      if code >= 200 and code < 300 or code >= 400 then         ettercap.log("HTTP_REQ: %s:%d -> %s:%d %s %s %d (%s)\n",            packet.dst_ip(p),            packet.dst_port(p),             packet.src_ip(p),             packet.src_port(p),             reg.request.verb ,reg.request.url , hobj.status_code, hobj.status_msg)

Dealing with the request and matching response is easy in this model. And we can easily add parsers for other types of traffic that aren't supported by Ettercap and Wireshark. When you put it all together, it gets very easy to track requests made by a browser in a MitM attack or from network capture files. Here's an example of how the initial requests from viewing Slashdot look, using our version of Ettercap with Lua modules enabled:


Note: we are printing both source and destination, the full request, status code, and in the case of a redirect, where the user was sent. This is just a brief example of the types of things that are going to be easy to build with this framework.

We will be releasing the source code for a patched Ettercap along with sample modules at SOURCE Boston.

If you're interesting in helping out or learning more, come see us and the other SpiderLabs folks at SOURCE Boston and chat with us about your ideas.

Latest SpiderLabs Blogs

Search & Spoof: Abuse of Windows Search to Redirect to Malware

Trustwave SpiderLabs has detected a sophisticated malware campaign that leverages the Windows search functionality embedded in HTML code to deploy malware. We found the threat actors utilizing a...

Read More

The Sentinel’s Watch: Building a Security Reporting Framework

Imagine being on shift as the guard of a fortress. Your job is to identify threats as they approach the perimeter. The more methods you have for detecting those threats, the better your chances of...

Read More

Fake Advanced IP Scanner Installer Delivers Dangerous CobaltStrike Backdoor

During a recent client investigation, Trustwave SpiderLabs found a malicious version of the Advanced IP Scanner installer, which contained a backdoored DLL module. Our client had been searching for...

Read More