Trustwave and Cybereason Merge to Form Global MDR Powerhouse for Unparalleled Cybersecurity Value. Learn More

Trustwave and Cybereason Merge to Form Global MDR Powerhouse for Unparalleled Cybersecurity Value. Learn More

Services
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.

Solutions
BY TOPIC
Microsoft Security
Unlock the full power of Microsoft Security
Offensive Security
Solutions to maximize your security ROI
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
Partners
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

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:

7982_113ba48d-f527-4f8c-b4f5-b72446628b7b

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.

ABOUT TRUSTWAVE

Trustwave is a globally recognized cybersecurity leader that reduces cyber risk and fortifies organizations against disruptive and damaging cyber threats. Our comprehensive offensive and defensive cybersecurity portfolio detects what others cannot, responds with greater speed and effectiveness, optimizes client investment, and improves security resilience. Learn more about us.

Latest Intelligence

Discover how our specialists can tailor a security program to fit the needs of
your organization.

Request a Demo