Skip to content
This repository was archived by the owner on Feb 28, 2019. It is now read-only.

Commit ff88153

Browse files
committed
network sniffer is now ready to use #version=0.1.3
1 parent 15ec2a6 commit ff88153

File tree

10 files changed

+1176
-347
lines changed

10 files changed

+1176
-347
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,4 @@ nosetests.xml
4949
# Pypy
5050
.pypirc
5151
.ropeproject
52+
.cache

CHANGELOG.md

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
# APTDetector Changelog
22

3-
Since February 7, 2016 there have been 0 releases and 2 commits for
3+
Since February 7, 2016 there have been 0 releases and 8 commits for
44

55
an average of zero 0-commit release every 0 weeks.
66

7+
## 0.1.3
8+
9+
* [BaseSniffer][basesniffer] is now finished and capable of parsing a [Pcap][Pcap] file
10+
* fixed doctests to pass travis ci
11+
712
## 0.1.2
813

14+
*(February 11, 2016)*
15+
916
* started documentating
1017
* fixed versioning problem
1118

@@ -35,4 +42,4 @@ Project Started.
3542
[CapTipper]: http://captipper.readthedocs.org/en/latest/
3643
[pcap-parser]: https://github.com/caoqianli/pcap-parser
3744
[URLSniffer]: https://github.com/abzcoding/aptdetector/blob/master/aptdetector/network/sniffer.py
38-
[Pcap]: https://en.wikipedia.org/wiki/Pcap
45+
[Pcap]: https://en.wikipedia.org/wiki/Pcap

README.md

+2-12
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,13 @@
66
*Advanced Persistent Threat Detection by Using Network Analysis*
77

88
**aptdetector** is a humble try to gather all means of malware detection
9-
109
from network analysis in one place, for educational purposes only.
1110

1211
* used [pcap-parser][pcap-parser] as the base for network analysis module
1312
* use [Cuckoo Sandbox][Cuckoo] as automated malware detection
1413

15-
aptdetector is tested against Python 3.4, 3.5, and
16-
17-
PyPy. [Full and extensive docs would be available at Read The Docs.][rtd]
18-
14+
aptdetector is tested against Python 3.4, 3.5, and PyPy.
15+
[Full and extensive docs would be available at Read The Docs.][rtd]
1916
See what's new by checking the [CHANGELOG][changelog].
2017

2118
[rtd]: https://aptdetector.readthedocs.org/en/latest/
@@ -41,7 +38,6 @@ Then, [thanks to PyPI][aptdetector_pypi], aptdetector is just an import away:
4138
```
4239

4340
However, due to the nature of utilities, application developers might
44-
4541
dependencies. See the [Integration][integration] section of the docs
4642

4743
[aptdetector_pypi]: https://pypi.python.org/pypi/aptdetector
@@ -50,15 +46,12 @@ dependencies. See the [Integration][integration] section of the docs
5046
## Disclaimer
5147

5248
Please do not use this program in production!!
53-
5449
it's an educational project only.
5550

5651

57-
5852
## References
5953

6054
I've based my work loosely on some respectful papers
61-
6255
that i've linked below:
6356

6457
* [Packet sniffing a brief introduction][packetsniff]
@@ -80,11 +73,8 @@ that i've linked below:
8073
## Gaps
8174

8275
Found something missing in the in `aptdetector`? something is broken in `aptdetector`?
83-
8476
If you are very motivated, submit [a Pull Request][prs]. Otherwise,
85-
8677
submit a short feature request on [the Issues page][issues], and we will
87-
8878
figure something out.
8979

9080
[architecture]: https://aptdetector.readthedocs.org/en/latest/architecture.html

aptdetector/network/packet.py

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
"""sample"""
2+
import socket
3+
4+
from aptdetector.utils.typecheck import params, returns
5+
6+
7+
class TcpPacket(object):
8+
"""mimic a TcpPacket as we need it"""
9+
10+
def __init__(self):
11+
"""initialize a :class:`TcpPacket`"""
12+
# splited = str(value).split('-')
13+
self.__sourceHost = None
14+
self.__sourcePort = None
15+
self.__destinationHost = None
16+
self.__destinationPort = None
17+
self.__url = None
18+
19+
def __str__(self):
20+
"""string representation of :class:TcpPacket object"""
21+
res = str(self.sourceHost + ":" + str(self.sourcePort) + " ---> " +
22+
self.destinationHost + ":" + str(
23+
self.destinationPort) + "\n" + self.request)
24+
return res
25+
26+
@returns(bool)
27+
def valid_ip(self, addr):
28+
"""check for valid ip"""
29+
try:
30+
socket.inet_aton(addr)
31+
return True
32+
except socket.error:
33+
return False
34+
35+
@property
36+
@returns(str)
37+
def sourceHost(self):
38+
"""sample"""
39+
return self.__sourceHost
40+
41+
@sourceHost.setter
42+
@params(self=object, value=str)
43+
def sourceHost(self, value):
44+
"""sample"""
45+
if self.valid_ip(value):
46+
self.__sourceHost = value
47+
48+
@property
49+
@returns(int)
50+
def sourcePort(self):
51+
"""sample"""
52+
return self.__sourcePort
53+
54+
@sourcePort.setter
55+
@params(self=object, value=int)
56+
def sourcePort(self, value):
57+
"""sample"""
58+
self.__sourcePort = value
59+
60+
@property
61+
@returns(str)
62+
def destinationHost(self):
63+
"""sample"""
64+
return self.__destinationHost
65+
66+
@destinationHost.setter
67+
@params(self=object, value=str)
68+
def destinationHost(self, value):
69+
"""sample"""
70+
if self.valid_ip(value):
71+
self.__destinationHost = value
72+
73+
@property
74+
@returns(int)
75+
def destinationPort(self):
76+
"""sample"""
77+
return self.__destinationPort
78+
79+
@destinationPort.setter
80+
@params(self=object, value=int)
81+
def destinationPort(self, value):
82+
"""sample"""
83+
self.__destinationPort = value
84+
85+
@property
86+
@returns(str)
87+
def request(self):
88+
"""sample"""
89+
return self.__url
90+
91+
@request.setter
92+
@params(self=object, value=str)
93+
def request(self, value):
94+
"""sample"""
95+
self.__url = value

0 commit comments

Comments
 (0)