![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Banned
![]() ![]() |
Retreiving outgoing packets
What module would you suggest I use to look into how I could go about retreiving and analyzing outgoing internet packets?
I'd like to be able to for a game I play, take the packets it sends while playing online and analyze those for a scoring program. |
|
|
|
|
|
#2 |
|
Expert Programmer
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4
![]() |
Cheater
. Never used one, tried googling for TCP packet sniffer? |
|
|
|
|
|
#3 |
|
Banned
![]() ![]() |
Okay. And I said analyzing it for a score tracking program. >_>
It will submit anyone's scores automatically to my website to be added to a database of everyones scores. If I used software it would be additional programs by clients would need to install. Plus it would probably be extremely difficult to automate the control and retrieval from already programmed software. |
|
|
|
|
|
#4 |
|
Banned
![]() ![]() |
Okay, I found something called Impacket. But I can't figure out how to use this example to retrieve outgoing packets... >_>
#!/usr/bin/python
# Copyright (c) 2003 CORE Security Technologies
#
# This software is provided under under a slightly modified version
# of the Apache Software License. See the accompanying LICENSE file
# for more information.
#
# $Id: ping.py,v 1.3 2003/10/27 17:36:56 jkohen Exp $
#
# Simple ICMP ping.
#
# This implementation of ping uses the ICMP echo and echo-reply packets
# to check the status of a host. If the remote host is up, it should reply
# to the echo probe with an echo-reply packet.
# Note that this isn't a definite test, as in the case the remote host is up
# but refuses to reply the probes.
# Also note that the user must have special access to be able to open a raw
# socket, which this program requires.
#
# Authors:
# Gerardo Richarte <gera@coresecurity.com>
# Javier Kohen <jkohen@coresecurity.com>
#
# Reference for:
# ImpactPacket: IP, ICMP, DATA.
# ImpactDecoder.
import select
import socket
import time
import sys
from impacket import ImpactDecoder, ImpactPacket
if len(sys.argv) < 3:
print "Use: %s <src ip> <dst ip>" % sys.argv[0]
sys.exit(1)
src = sys.argv[1]
dst = sys.argv[2]
# Create a new IP packet and set its source and destination addresses.
ip = ImpactPacket.IP()
ip.set_ip_src(src)
ip.set_ip_dst(dst)
# Create a new ICMP packet of type ECHO.
icmp = ImpactPacket.ICMP()
icmp.set_icmp_type(icmp.ICMP_ECHO)
# Include a 156-character long payload inside the ICMP packet.
icmp.contains(ImpactPacket.Data("A"*156))
# Have the IP packet contain the ICMP packet (along with its payload).
ip.contains(icmp)
# Open a raw socket. Special permissions are usually required.
s = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_ICMP)
s.setsockopt(socket.IPPROTO_IP, socket.IP_HDRINCL, 1)
seq_id = 0
while 1:
# Give the ICMP packet the next ID in the sequence.
seq_id += 1
icmp.set_icmp_id(seq_id)
# Calculate its checksum.
icmp.set_icmp_cksum(0)
icmp.auto_checksum = 1
# Send it to the target host.
s.sendto(ip.get_packet(), (dst, 0))
# Wait for incoming replies.
if s in select.select([s],[],[],1)[0]:
reply = s.recvfrom(2000)[0]
# Use ImpactDecoder to reconstruct the packet hierarchy.
rip = ImpactDecoder.IPDecoder().decode(reply)
# Extract the ICMP packet from its container (the IP packet).
ricmp = rip.child()
# If the packet matches, report it to the user.
if rip.get_ip_dst() == src and rip.get_ip_src() == dst and icmp.ICMP_ECHOREPLY == ricmp.get_icmp_type():
print "Ping reply for sequence #%d" % ricmp.get_icmp_id()
time.sleep(1)This works on my computer, It pings my server and works fine. Any ideas? |
|
|
|
|
|
#5 |
|
Banned
![]() ![]() |
Yeah, it seems impacket is for recieving and decoding packets come TO your computer, not FROM.
Pleeeze. I hate to triple post but this is really bugging my and I'm pressed for time. |
|
|
|
|
|
#6 |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
As I understand it, getting outgoing packages depends on your OS. Essentially, you query your TCP/IP implentation for information, and the interface to do so is, I believe, tied to the kernel. I'd guess that the program whose traffic you wish to monitor runs on Windows, so you'd need to research how to monitor TCP/IP packets from Windows.
Perhaps try http://oss.coresecurity.com/projects/pcapy.html, which is a python library that interfaces with http://www.winpcap.org/windump/. Alternatively, you could set up a router program, that takes in the information from your game, and passes it on to the game servers, monitoring the data as it passes through. Of course, this would either require the users changing the game servers used by the game (if this is even possible), or changing the hosts file to redirect data meant for the game server to your program. But neither of which is anythin close to an ideal solution. |
|
|
|
|
|
#7 |
|
Banned
![]() ![]() |
I've looked at pcapy and it's essentially the same thing as Impacket.
The ideal solution for me is something that'll be consistently compatible on Windows, router or not. I don't see why you can't just simply view your outgoing traffic, it just seems so simple. ![]() |
|
|
|
|
|
#8 | |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
Quote:
|
|
|
|
|
|
|
#9 |
|
Banned
![]() ![]() |
XD
That response made me laugh. ^_^ Is there a way I can just use tcpdump instead of these silly interfaces to them? Is there anyway this also could be illegal? The game says it's against the TOS to modify packets, but what about reading them? |
|
|
|
|
|
#10 |
|
Expert Programmer
|
Well tcpdump is a *nix program, you could pipe it to stdin and parse the output.
I'm not sure how you'd do that on windows, but i saw a windows version call windump.
__________________
Join us at #programmingforums @ irc.freenode.net! My software never has bugs. It just develops random features.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|