Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
156 commits
Select commit Hold shift + click to select a range
631d7bf
Added FlowSet With Template ID 260
9nehS Sep 26, 2017
a959942
Rewrite pygennf_v9 to make it more powerful to use
9nehS Sep 26, 2017
b7753e9
Update setup personal message
Sep 26, 2017
aab9e06
Add sport and dport for gen_send_pkt()
Sep 26, 2017
00d3ff3
Add src_ip and dst_ip for gen_send_pkt()
Sep 26, 2017
5b07826
Set verbose=0 in send()
Sep 26, 2017
0d57b05
Added stdout.write() in gen_send_pkt()
Sep 26, 2017
f5be354
Replace print with sys.stdout.write()
Sep 26, 2017
804b1f4
Added '\r\n' in sys.stdout.write() in gen_send_pkt()
Sep 26, 2017
15f000c
Not to display len_flow and len_padding
Sep 26, 2017
58751bb
Add info message in main()
Sep 26, 2017
bba99fe
Update install part
Sep 27, 2017
2f1376f
Update install part
Sep 27, 2017
45dbfc6
Delete .rpm and .tar.gz
Sep 27, 2017
067260c
Add args.protocol in order to specify protocol
Sep 27, 2017
7c6d5c4
Add args.bytes in order to specify bytes(octets) in netflow data
Sep 27, 2017
e89b8bc
Update help info
Sep 27, 2017
9acebd0
Update README
Sep 27, 2017
2e50f21
Update README
Sep 27, 2017
98313f4
Update README
Sep 27, 2017
152b129
Update README
Sep 27, 2017
924bf48
Remove files not needed
Sep 27, 2017
ba36417
Add snapshots
Sep 27, 2017
d825cb3
Update - added links to snapshots
Sep 27, 2017
f564a9b
Remove udpnf.py
Sep 27, 2017
be5444f
Remove .egg
Sep 27, 2017
52bb094
Update - comment wrpcap()
Sep 27, 2017
0243dee
Update - only keep v9
Sep 27, 2017
4eeedd2
Update - modify help info
Sep 27, 2017
5efc9f4
Update - modify description
Sep 27, 2017
4e04d07
Update - Change name
Sep 28, 2017
0043312
Update - Change name
Sep 28, 2017
610c620
Added args.flows_data
Sep 28, 2017
352090e
Update gen_pkt_netflow_data() to process flow_data_list
Sep 28, 2017
f6bff35
Update gen_pkt_netflow_data() to process flow_data_list
Sep 28, 2017
c8b80f7
Update gen_pkt_netflow_data() to process flow_data_list
Sep 28, 2017
ab6a861
Update gen_pkt_netflow_data() to process flow_data_list
Sep 28, 2017
d7daee7
Update gen_pkt_netflow_data() to process flow_data_list
Sep 28, 2017
6dbd9bb
Update gen_pkt_netflow_data() to process flow_data_list
Sep 28, 2017
4d600f5
Update gen_pkt_netflow_data() to process flow_data_list
Sep 28, 2017
cf4dfc6
Update gen_pkt_netflow_data() to process flow_data_list
Sep 28, 2017
0c6c364
Update gen_pkt_netflow_data() to process flow_data_list
Sep 28, 2017
d5c2d0b
Update gen_pkt_netflow_data() to process flow_data_list
Sep 28, 2017
1a604cb
Update the logic to process args.flows_data
Sep 28, 2017
de224d6
Update the logic to process args.flows_data
Sep 28, 2017
11e2e21
Update the logic to process args.flows_data
Sep 28, 2017
ede6239
Update the logic to process args.flows_data
Sep 28, 2017
af317ca
Update the logic to process args.flows_data
Sep 28, 2017
13276b8
Remove args.protocol and args.bytes
Sep 28, 2017
3bd857d
Remove args.protocol and args.bytes
Sep 28, 2017
d410a15
Add console snapshot
Sep 28, 2017
c05b710
Update README
Sep 28, 2017
3f886ad
Add WEB snapshot
Sep 28, 2017
eafb36a
Update README
Sep 28, 2017
9324936
Remove old snapshots
Sep 29, 2017
0214949
Update comments
Sep 30, 2017
de54295
Update banner with ascii art
Sep 30, 2017
8ecb962
Update banner with ascii art
Sep 30, 2017
20c01fc
Remove legacy and added latest console snapshot
Sep 30, 2017
b73362b
Update snapshot link in README
Sep 30, 2017
eb07fd4
Update snapshot link in README
Sep 30, 2017
0058916
To add multi threads capability
9nehS Oct 31, 2017
dcddb62
To add multi threads capability in main()
9nehS Oct 31, 2017
f901dd7
To include the multi threads file
9nehS Oct 31, 2017
39e174b
To include the multi threads file
9nehS Oct 31, 2017
8129715
To include the multi threads file
9nehS Oct 31, 2017
c39bb0b
To include the multi threads file
9nehS Oct 31, 2017
da73ccf
To include the multi threads file
9nehS Oct 31, 2017
ce4583b
To include the multi threads file
9nehS Oct 31, 2017
bab4a56
To include the multi threads file
9nehS Oct 31, 2017
a6289b0
To include the multi threads file
9nehS Oct 31, 2017
842167c
To include the multi threads file
9nehS Oct 31, 2017
e6163b2
To include the multi threads file
9nehS Oct 31, 2017
4b27784
To include the multi threads file
9nehS Nov 1, 2017
8aa8822
Add web_api.py
9nehS Dec 12, 2017
4d27eb7
Add __init__.py
9nehS Dec 12, 2017
6a1ef44
Add __init__.py
9nehS Dec 12, 2017
baa615e
Add web_api.py in setup.py
9nehS Dec 12, 2017
f31019b
Change the location for web_api dir
9nehS Dec 12, 2017
c99e422
Add web_api for packages
9nehS Dec 12, 2017
7cfa99a
Change import statement
9nehS Dec 12, 2017
912a7e3
Add find_packages()
9nehS Dec 12, 2017
6272b9c
Update import for web_api
9nehS Dec 12, 2017
131e9d3
Update import for web_api
9nehS Dec 13, 2017
6c3d8f0
Update packages
9nehS Dec 13, 2017
7b52ff9
Update argument '-r'
9nehS Dec 13, 2017
22ca83a
Add port=9080
9nehS Dec 13, 2017
2d4cd41
Refactor some variables
9nehS Dec 13, 2017
6bcb93d
Add method send()
9nehS Dec 13, 2017
d10b79d
Add method send()
9nehS Dec 13, 2017
069a3ed
Add method send()
9nehS Dec 13, 2017
52ce3f1
Add method send()
9nehS Dec 13, 2017
1416dba
Add method send()
9nehS Dec 13, 2017
2edec44
Add debug print
9nehS Dec 13, 2017
3952c1e
Add debug print
9nehS Dec 13, 2017
828c3eb
Add import
9nehS Dec 13, 2017
b7170ec
Update packages
9nehS Dec 13, 2017
b5686bf
Update packages
9nehS Dec 13, 2017
788ec94
Update import
9nehS Dec 13, 2017
f83a860
Update packages
9nehS Dec 13, 2017
48c9c2a
Merge web_api
9nehS Dec 13, 2017
3cb8473
Add debug print
9nehS Dec 13, 2017
0afe91d
Add debug print
9nehS Dec 13, 2017
e99daa0
Add unicode conversion
9nehS Dec 13, 2017
67fa257
Change URL
9nehS Dec 13, 2017
bfbbca4
Change thread behavior
9nehS Dec 13, 2017
adaa506
Add return content for create()
9nehS Dec 13, 2017
e386f1d
Remove some comments
9nehS Dec 13, 2017
99ae7c2
Add logger
9nehS Dec 14, 2017
68603fc
Add logger print
9nehS Dec 14, 2017
c0571e8
Add module utils
9nehS Dec 14, 2017
967eb3b
Add sys in import
9nehS Dec 14, 2017
27e0dc7
Updated naming error for logger
9nehS Dec 14, 2017
db68cf0
Updated import for logger
9nehS Dec 14, 2017
5bb8799
Updated logger output in create()
9nehS Dec 14, 2017
8fac636
Updated logger output in get_flow_data_list()
9nehS Dec 14, 2017
d7ea6f5
Updated logger output
9nehS Dec 14, 2017
9fca431
Updated logger output
9nehS Dec 14, 2017
4022794
Remove package web_api
9nehS Dec 14, 2017
5b1dadb
Added util for uuid
9nehS Dec 14, 2017
c9bb20d
Added thread list
9nehS Dec 14, 2017
e471f41
Added /pygennf/help and /pygennf/tasks/status
9nehS Dec 14, 2017
04aba65
Updated return value in status()
9nehS Dec 14, 2017
172f6fb
Updated returned dict in status()
9nehS Dec 14, 2017
c78fd6d
Updated returned dict in status()
9nehS Dec 14, 2017
6ed4391
Updated return info in create()
9nehS Dec 14, 2017
e52ea91
Changed thread name to uuid in create()
9nehS Dec 14, 2017
6f45add
Changed threads_dict in create()
9nehS Dec 14, 2017
d5c44e2
Add pkt_sent in threads_dict
9nehS Dec 14, 2017
2701b37
Changed the status_info_dict in status()
9nehS Dec 14, 2017
b9508f1
Add parameter 'remote' in gen_send_pkt()
9nehS Dec 18, 2017
d16fd87
Modify default app port
9nehS Dec 18, 2017
1511fe2
Add end_time in threads_dict
9nehS Dec 18, 2017
4622de9
Add debug log in start_send
9nehS Dec 18, 2017
5479bcf
Update output in status()
9nehS Dec 18, 2017
c53d117
Add API to support query for specific task
9nehS Dec 19, 2017
d00cf24
Add API to support query for specific task
9nehS Dec 19, 2017
bfbe4aa
Add API to support query for specific task
9nehS Dec 19, 2017
37332ec
Add status in task info returned
9nehS Dec 19, 2017
c38bb35
Add status in task info returned
9nehS Dec 19, 2017
47b7121
Add method for task killing
9nehS Dec 19, 2017
5aa6956
Add method for task killing
9nehS Dec 19, 2017
9d38432
Add method for all tasks stopping
9nehS Dec 19, 2017
a83a173
Change from uuid1 to uuid4
9nehS Dec 19, 2017
51945ee
Add detail_all() to return all tasks details
9nehS Jan 15, 2018
566023b
Add detail_specific() to return specific task detail
9nehS Jan 15, 2018
8e017d3
Add clear() to clear task list
9nehS Jan 15, 2018
71e1e85
Rename remote to is_remote
9nehS Feb 5, 2018
b03e972
Update README
9nehS Feb 5, 2018
536c668
Update README
9nehS Feb 5, 2018
2d51d42
Rename to pygennf_v9_dev.py
9nehS Feb 5, 2018
fe176f5
Rename to pygennf_v9_dev.py
9nehS Feb 5, 2018
f764a24
Rename to pygennf_v9_dev.py
9nehS Feb 5, 2018
e8b933f
Update help info
9nehS Feb 6, 2018
25f5815
Add snapshot for remote mode
9nehS May 11, 2018
370e7cf
Add remote part
9nehS May 11, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 0 additions & 44 deletions README

This file was deleted.

97 changes: 55 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,55 +1,68 @@
# pygennf

Netflow packets generator with Scape library

* Download it! [https://github.com/redBorder/pygennf/tree/master/download]

> rpm: (python2.6) wget https://github.com/redBorder/pygennf/raw/master/download/pygennf-0.1-1.noarch.rpm

> tar.gz: wget https://github.com/redBorder/pygennf/raw/master/download/pygennf-0.1.tar.gz
Netflow packets generator with Scapy library

* How to install:
python setup.py install

* How to install the rpm packege:
rpm -vUh pygennf-0.1-1.noarch.rpm

# Usage (without installation):

* You need to install the scapy library:
pip install scapy

* python ./pygennf_v5.py --help

> usage: pygennf_v5.py [-h] [-s SRC_IP] [-sp SRC_PORT] [-d DST_IP]
> [-dp DST_PORT] [-t TIME_INTERVAL]
>
> UDP packets producer with scapy
>
> optional arguments:
> git clone https://github.com/9nehS/pygennf.git
>
> git checkout dev_multi_threads
>
> python setup.py install --force

# Usage:

* pygennf_v9_dev.py --help

>usage: pygennf_v9_dev.py [-h] [-s SRC_IP] [-sp SRC_PORT] [-d DST_IP]
> [-dp DST_PORT] [-t TIME_INTERVAL]
> [-c PKT_COUNT] [-fd FLOWS_DATA] [-r]
> [-ll {info,debug}]
>
>Netflow packets generator with scapy
>
>optional arguments:
>
> -h, --help show this help message and exit

>
> -s SRC_IP, --source-ip SRC_IP
> IP source

> Source IP of netflow packet(s).
>
> -sp SRC_PORT, --source-port SRC_PORT
> Port dst

> Source port of netflow packet(s).
>
> -d DST_IP, --dst-ip DST_IP
> IP source

> Destination IP of netflow packet(s).
>
> -dp DST_PORT, --dst-port DST_PORT
> Port dst

> Destination port of netflow packet(s).
>
> -t TIME_INTERVAL, --time-interval TIME_INTERVAL
Time interval to wait to send other messages.
> Time interval to wait before sending each netflow packet.
>
> -c PKT_COUNT, --pkt-count PKT_COUNT
> Packets count to be sent before this generator stopping.
>
> -fd FLOWS_DATA, --flows-data FLOWS_DATA
> Contents in flows data, e.g. ip1/mask:port1:ip2/mask:port2:protocol:direction:bytes.
>
> -r, --remote
> Listen on TCP port 15000 as API server. All other parameters will be ignored.
>
> -ll {info,debug}, --log-level {info,debug}
> Log level, default log level is info
>

# Example of use:

* Netflow 5:
> sudo python src/pygennf_v5.py -s 10.0.203.2 -d 10.0.30.89 -t 2
* Netflow 9:
> sudo python src/pygennf_v9.py -s 10.0.203.2 -d 10.0.30.89 -t 2
* Netflow 10:
> sudo python src/pygennf_v10.py -s 10.0.203.2 -d 10.0.30.89 -t 2
# Example of use:

* Netflow 9 (CLI):
> pygennf_v9_dev.py --source-ip 10.9.255.54 --dst-ip 10.9.255.118 --dst-port 2062 -t 1 -c 3600 -fd '69.31.102.10/32:12345:209.81.108.20/32:80:tcp:ingress:1024, 70.32.103.11/32:54321:210.81.108.21/32:21:udp:ingress:1024'
>
> ![2017-09-30_console_snapshot_01.png](https://github.com/9nehS/pygennf/blob/master/resources/2017-09-30_console_snapshot_01.png)
>
> ![2017-09-28_web_snapshot_01.png](https://github.com/9nehS/pygennf/blob/master/resources/2017-09-28_web_snapshot_01.png)
>
* Netflow 9 (WebService):
> pygennf_v9_dev.py --remote
>
> ![2018-05-11_remote.png](https://github.com/9nehS/pygennf/blob/master/resources/2018-05-11_remote.png)
Binary file removed download/pygennf-0.1-1.noarch.rpm
Binary file not shown.
Binary file removed download/pygennf-0.1.tar.gz
Binary file not shown.
Binary file removed pygennf-0.1-1.noarch.rpm
Binary file not shown.
Binary file removed pygennf-0.1-py2.7.egg
Binary file not shown.
Binary file removed pygennf-0.1.tar.gz
Binary file not shown.
40 changes: 39 additions & 1 deletion rb_netflow/rb_netflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
## Copyright (C) Philippe Biondi <phil@secdev.org>
## This program is published under a GPLv2 license
## Netflow V5 appended by spaceB0x and Guillaume Valadon
## Netflow v9 with template ID 260 appended by Sheng

"""
Cisco NetFlow protocol v1 and v5
Cisco NetFlow protocol v1, v5, v9 and v10
"""


Expand Down Expand Up @@ -283,3 +284,40 @@ class Flow_v9(Packet):
bind_layers( NetFlowTemplatev10Field, NetFlowTemplatev10FieldPEN, version=5)
#bind_layers( NetflowHeaderV5, NetflowRecordV5 )
#bind_layers( NetflowRecordV5, NetflowRecordV5 )


# FlowSet With Template ID 260

class Flow_260_v9(Packet):
name = "Element flow (v9) for template id 260"
fields_desc = [
IntField('Packets', 1),
IntField('Octets', 1000),
IPField('SrcAddr', '11.11.11.11'),
IPField('DstAddr', '22.22.22.22'),
IntField('InputInt', 100),
IntField('OutputInt', 101),
IntField('EndTime', 3569615),
IntField('StartTime', 3569614),
ShortField("SrcPort", 8888),
ShortField("DstPort", 80),
IntField('SrcAS', 0),
IntField('DstAS', 0),
IPField('BGPNextHop', '0.0.0.0'),
ByteField("SrcMask", 24),
ByteField("DstMask", 24),
ByteField("Protocol", 6),
XByteField("TCPFlags", 0x10),
XByteField("IPToS", 0x00),
ByteField("Direction", 0),
XByteField("ForwardingStatus", 0x40),
ShortField("SamplerID", 2),
XIntField("IngressVRFID", 0x60000000),
XIntField("EgressVRFID", 0x60000000)
]


bind_layers( NetFlowTemplatev10Field, NetFlowTemplatev10FieldPEN, version=5)
#bind_layers( NetflowHeaderV5, NetflowRecordV5 )
#bind_layers( NetflowRecordV5, NetflowRecordV5 )

Binary file added resources/2017-09-28_web_snapshot_01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/2017-09-30_console_snapshot_01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/2018-05-11_remote.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 10 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
from setuptools import setup

setup(name="pygennf",
version="0.1",
description="UDP packets producer with scapy",
author="Ana Rey",
author_email="anarey@redborder.com",
url="https://github.com/redBorder/",
version="0.11",
description="Netflow packets generator with scapy",
author="Sheng Zhao",
author_email="sheng.zhao@calix.com",
url="https://github.com/9nehS/",
license="AGPL",
scripts=["src/pygennf_v5.py", "src/pygennf_v9.py", "src/pygennf_v10.py" ],
packages=['rb_netflow'],
scripts=["src/pygennf_v9.py", "src/pygennf_v9_dev.py"],
packages=['rb_netflow', 'utils'],
# packages=find_packages(),
install_requires=[
'scapy',
'flask'
]
)
)
Empty file added src/__init__.py
Empty file.
8 changes: 4 additions & 4 deletions src/pygennf_v10.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@

import rb_netflow.rb_netflow as rbnf

signal_received = 0
SIGNAL_RECEIVED = 0

def preexec():
os.setpgrp() # Don't forward signals

def signal_handler(signal, frame):
global signal_received
signal_received = 1
global SIGNAL_RECEIVED
SIGNAL_RECEIVED = 1

def main():
if os.getuid() != 0:
Expand Down Expand Up @@ -188,7 +188,7 @@ def main():
send(data)

while TIME_INTERVAL is not 0:
if signal_received == 1:
if SIGNAL_RECEIVED == 1:
print "\nSignal received. Stopping and Exitting..."
sys.exit(0)
time.sleep(float(TIME_INTERVAL))
Expand Down
8 changes: 4 additions & 4 deletions src/pygennf_v5.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@

import rb_netflow.rb_netflow as rbnf

signal_received = 0
SIGNAL_RECEIVED = 0

def preexec():
os.setpgrp() # Don't forward signals

def signal_handler(signal, frame):
global signal_received
signal_received = 1
global SIGNAL_RECEIVED
SIGNAL_RECEIVED = 1

def main():
if os.getuid() != 0:
Expand Down Expand Up @@ -323,7 +323,7 @@ def main():
send(data)

while TIME_INTERVAL is not 0:
if signal_received == 1:
if SIGNAL_RECEIVED == 1:
print "\nSignal received. Stopping and Exitting..."
sys.exit(0)
time.sleep(float(TIME_INTERVAL))
Expand Down
Loading