diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ad8374e --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +venv/ +charging/__pycache__/ +charging/ipmininet/topologies/__pycache__/ +charging/db.sqlite3 +Todo.md +mitm/__pycache__ \ No newline at end of file diff --git a/charging/__pycache__/__init__.cpython-310.pyc b/charging/__pycache__/__init__.cpython-310.pyc deleted file mode 100644 index 3c2baee..0000000 Binary files a/charging/__pycache__/__init__.cpython-310.pyc and /dev/null differ diff --git a/charging/__pycache__/__init__.cpython-312.pyc b/charging/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index b5e356d..0000000 Binary files a/charging/__pycache__/__init__.cpython-312.pyc and /dev/null differ diff --git a/charging/__pycache__/api_client.cpython-310.pyc b/charging/__pycache__/api_client.cpython-310.pyc deleted file mode 100644 index b0174ff..0000000 Binary files a/charging/__pycache__/api_client.cpython-310.pyc and /dev/null differ diff --git a/charging/__pycache__/client.cpython-310.pyc b/charging/__pycache__/client.cpython-310.pyc deleted file mode 100644 index d71fa86..0000000 Binary files a/charging/__pycache__/client.cpython-310.pyc and /dev/null differ diff --git a/charging/__pycache__/db.cpython-310.pyc b/charging/__pycache__/db.cpython-310.pyc deleted file mode 100644 index 31242d7..0000000 Binary files a/charging/__pycache__/db.cpython-310.pyc and /dev/null differ diff --git a/charging/__pycache__/db.cpython-312.pyc b/charging/__pycache__/db.cpython-312.pyc deleted file mode 100644 index 6c367c8..0000000 Binary files a/charging/__pycache__/db.cpython-312.pyc and /dev/null differ diff --git a/charging/__pycache__/proxy.cpython-310.pyc b/charging/__pycache__/proxy.cpython-310.pyc deleted file mode 100644 index 435f103..0000000 Binary files a/charging/__pycache__/proxy.cpython-310.pyc and /dev/null differ diff --git a/charging/client.py b/charging/client.py index 63631cd..683e059 100644 --- a/charging/client.py +++ b/charging/client.py @@ -8,6 +8,9 @@ from datetime import datetime, timezone from typing import List, Optional, Callable, Awaitable, Dict, Any import base64 +#import logging +#logging.basicConfig(level=logging.DEBUG) +#logging.getLogger("websockets").setLevel(logging.DEBUG) import aioconsole import websockets @@ -1043,7 +1046,7 @@ async def launch_client( credentials = create_basic_auth64(serial_number, bytes(CONFIGURATION['AuthorizationKey'], 'utf-8')) else: if SECURITY_CTRL['BasicAuthPassword']: - credentials = f'{SECURITY_CTRL['Identity']}:{SECURITY_CTRL['BasicAuthPassword']}'.encode('utf-8') + credentials = f"{SECURITY_CTRL['Identity']}:{SECURITY_CTRL['BasicAuthPassword']}".encode('utf-8') credentials = base64.b64encode(credentials).decode('utf-8') if VERSION == 'v1.6': diff --git a/charging/client_config.yaml b/charging/client_config.yaml index 79aa8ef..53dea00 100644 --- a/charging/client_config.yaml +++ b/charging/client_config.yaml @@ -8,7 +8,7 @@ comm: - 2 NetworkProfileConnectionAttempts: 2 OfflineThreshold: 30 -ip: fe80::e3a6:46e4:bff9:fb8e%ens33 +ip: fe80::20c:29ff:fe0a:aa2b%ens160 model: E2507 port0: 9000 port1: 9001 @@ -21,17 +21,17 @@ port7: 9007 profiles: 0: SP: 1 - ip: fe80::e3a6:46e4:bff9:fb8e%ens33 + ip: fe80::20c:29ff:fe0a:aa2b%ens160 message_timeout: 30 ocpp_version: OCPP201 1: SP: 2 - ip: fe80::e3a6:46e4:bff9:fb8e%ens33 + ip: fe80::20c:29ff:fe0a:aa2b%ens160 message_timeout: 30 ocpp_version: OCPP201 2: SP: 3 - ip: fe80::e3a6:46e4:bff9:fb8e%ens33 + ip: fe80::20c:29ff:fe0a:aa2b%ens160 message_timeout: 30 ocpp_version: OCPP201 security: diff --git a/charging/cso.py b/charging/cso.py index abe13db..5e1a392 100644 --- a/charging/cso.py +++ b/charging/cso.py @@ -16,7 +16,7 @@ if args.server: ip = args.server else: - ip = 'fe80::e3a6:46e4:bff9:fb8e%ens33' + ip = 'fe80::e3a6:46e4:bff9:fb8e%ens160' cmd_list = ['list', 'exit', 'help', 'install', 'get', 'setProfile', 'setVariable', 'trigger', 'ping'] diff --git a/charging/db.sqlite3 b/charging/db.sqlite3 deleted file mode 100644 index 3e29b37..0000000 Binary files a/charging/db.sqlite3 and /dev/null differ diff --git a/charging/installedCertificates/E2507-1679-2851/root/emuocpp_ttp_cert.pem b/charging/installedCertificates/E2507-1679-2851/root/emuocpp_ttp_cert.pem new file mode 100644 index 0000000..5baf989 --- /dev/null +++ b/charging/installedCertificates/E2507-1679-2851/root/emuocpp_ttp_cert.pem @@ -0,0 +1,14 @@ +-----BEGIN CERTIFICATE----- +MIICITCCAaagAwIBAgIUG2E3NLVfVrjtKpgyuZk/3CK3s+swCgYIKoZIzj0EAwMw +XzELMAkGA1UEBhMCQU4xEjAQBgNVBAgMCUFub255bW91czESMBAGA1UEBwwJQW5v +bnltb3VzMRMwEQYDVQQKDApFbXVPQ1BQLUNBMRMwEQYDVQQDDApFbXVPQ1BQLUNB +MB4XDTI1MDIxNDE0NDMxNFoXDTM1MDIxMjE0NDMxNFowXzELMAkGA1UEBhMCQU4x +EjAQBgNVBAgMCUFub255bW91czESMBAGA1UEBwwJQW5vbnltb3VzMRMwEQYDVQQK +DApFbXVPQ1BQLUNBMRMwEQYDVQQDDApFbXVPQ1BQLUNBMHYwEAYHKoZIzj0CAQYF +K4EEACIDYgAEH4T4Jn6VnDB4R1ml5tJSmw9KgNUJ1rQtdhOAJYe4M7sCIKi2fwTG +MWOHM/MtmhGrZLGo2E/oozeGUx+WBWySeFBl99PqRHHPGS3iD1gU2Vq1WUSNmgFq +cXu7GlsA8iXfoyMwITAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAK +BggqhkjOPQQDAwNpADBmAjEA7YhKNUVyAAgb/y0tt/G9sTjnk07H+Wu2lh5EzqHk +fL6LSFMlCt7PDogND0QGd5FeAjEAp3c/pRsFujBy9sWntDGrZ7O2pomPbjI2J365 +lvCLKWDAgbIB0unmfaheISNULSmu +-----END CERTIFICATE----- diff --git a/charging/installedCertificates/E2507-8420-1274/root/rootCert_1.pem b/charging/installedCertificates/E2507-8420-1274/root/rootCert_1.pem index 5e7a409..5baf989 100644 --- a/charging/installedCertificates/E2507-8420-1274/root/rootCert_1.pem +++ b/charging/installedCertificates/E2507-8420-1274/root/rootCert_1.pem @@ -1,14 +1,14 @@ -----BEGIN CERTIFICATE----- -MIICGTCCAaCgAwIBAgIUMi0FHauwv9+IELU2BeusLlOfapowCgYIKoZIzj0EAwMw -XDELMAkGA1UEBhMCQU4xEjAQBgNVBAgMCUFub255bW91czESMBAGA1UEBwwJQW5v -bnltb3VzMRIwEAYDVQQKDAlNSVRNUHJveHkxETAPBgNVBAMMCG1pdG0uY29tMB4X -DTI1MDIxNDE1NDUyNFoXDTM1MDIxMjE1NDUyNFowXDELMAkGA1UEBhMCQU4xEjAQ -BgNVBAgMCUFub255bW91czESMBAGA1UEBwwJQW5vbnltb3VzMRIwEAYDVQQKDAlN -SVRNUHJveHkxETAPBgNVBAMMCG1pdG0uY29tMHYwEAYHKoZIzj0CAQYFK4EEACID -YgAEhzvUOAN1Il4wDs78hND4XveQT6vDWts67mg2CMcA4SBj1Gz5j9msLameUDG4 -pEt1jbO6G1lSq1Bzhug9FwNSuaSRI0EnMDBQuLy0VmwiN10IqBk6wk/AKdtxO5OD -5HjnoyMwITAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAKBggqhkjO -PQQDAwNnADBkAjByiuPHDTyir9Xl2PwepcPBAKsxVOG9luHb/B+2t+TKCAWKjwgP -7t9caZudY2fg2AYCMGPCK4/Efg5k9pMZ1OTPEeyZsTgr1Fy6Umc02dUTfqVkl0O0 -p0+8+CFLdhzAdOBuDQ== +MIICITCCAaagAwIBAgIUG2E3NLVfVrjtKpgyuZk/3CK3s+swCgYIKoZIzj0EAwMw +XzELMAkGA1UEBhMCQU4xEjAQBgNVBAgMCUFub255bW91czESMBAGA1UEBwwJQW5v +bnltb3VzMRMwEQYDVQQKDApFbXVPQ1BQLUNBMRMwEQYDVQQDDApFbXVPQ1BQLUNB +MB4XDTI1MDIxNDE0NDMxNFoXDTM1MDIxMjE0NDMxNFowXzELMAkGA1UEBhMCQU4x +EjAQBgNVBAgMCUFub255bW91czESMBAGA1UEBwwJQW5vbnltb3VzMRMwEQYDVQQK +DApFbXVPQ1BQLUNBMRMwEQYDVQQDDApFbXVPQ1BQLUNBMHYwEAYHKoZIzj0CAQYF +K4EEACIDYgAEH4T4Jn6VnDB4R1ml5tJSmw9KgNUJ1rQtdhOAJYe4M7sCIKi2fwTG +MWOHM/MtmhGrZLGo2E/oozeGUx+WBWySeFBl99PqRHHPGS3iD1gU2Vq1WUSNmgFq +cXu7GlsA8iXfoyMwITAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAK +BggqhkjOPQQDAwNpADBmAjEA7YhKNUVyAAgb/y0tt/G9sTjnk07H+Wu2lh5EzqHk +fL6LSFMlCt7PDogND0QGd5FeAjEAp3c/pRsFujBy9sWntDGrZ7O2pomPbjI2J365 +lvCLKWDAgbIB0unmfaheISNULSmu -----END CERTIFICATE----- diff --git a/charging/installedCertificates/E2507-9346-3155/root/emuocpp_ttp_cert.pem b/charging/installedCertificates/E2507-9346-3155/root/emuocpp_ttp_cert.pem new file mode 100644 index 0000000..5baf989 --- /dev/null +++ b/charging/installedCertificates/E2507-9346-3155/root/emuocpp_ttp_cert.pem @@ -0,0 +1,14 @@ +-----BEGIN CERTIFICATE----- +MIICITCCAaagAwIBAgIUG2E3NLVfVrjtKpgyuZk/3CK3s+swCgYIKoZIzj0EAwMw +XzELMAkGA1UEBhMCQU4xEjAQBgNVBAgMCUFub255bW91czESMBAGA1UEBwwJQW5v +bnltb3VzMRMwEQYDVQQKDApFbXVPQ1BQLUNBMRMwEQYDVQQDDApFbXVPQ1BQLUNB +MB4XDTI1MDIxNDE0NDMxNFoXDTM1MDIxMjE0NDMxNFowXzELMAkGA1UEBhMCQU4x +EjAQBgNVBAgMCUFub255bW91czESMBAGA1UEBwwJQW5vbnltb3VzMRMwEQYDVQQK +DApFbXVPQ1BQLUNBMRMwEQYDVQQDDApFbXVPQ1BQLUNBMHYwEAYHKoZIzj0CAQYF +K4EEACIDYgAEH4T4Jn6VnDB4R1ml5tJSmw9KgNUJ1rQtdhOAJYe4M7sCIKi2fwTG +MWOHM/MtmhGrZLGo2E/oozeGUx+WBWySeFBl99PqRHHPGS3iD1gU2Vq1WUSNmgFq +cXu7GlsA8iXfoyMwITAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAK +BggqhkjOPQQDAwNpADBmAjEA7YhKNUVyAAgb/y0tt/G9sTjnk07H+Wu2lh5EzqHk +fL6LSFMlCt7PDogND0QGd5FeAjEAp3c/pRsFujBy9sWntDGrZ7O2pomPbjI2J365 +lvCLKWDAgbIB0unmfaheISNULSmu +-----END CERTIFICATE----- diff --git a/charging/ipmininet/launch.py b/charging/ipmininet/launch.py index d92057f..bd51479 100644 --- a/charging/ipmininet/launch.py +++ b/charging/ipmininet/launch.py @@ -178,7 +178,7 @@ def run_topology(topology_module_name): while True: try: config['security']['BasicAuthPassword'] = auth_key - print(f'AuthKey: {config['security']['BasicAuthPassword']}') + print(f"AuthKey: {config['security']['BasicAuthPassword']}") except Exception as e: print(e) time.sleep(2) diff --git a/charging/ipmininet/topologies/__pycache__/ConfigTopo.cpython-310.pyc b/charging/ipmininet/topologies/__pycache__/ConfigTopo.cpython-310.pyc deleted file mode 100644 index 10febfe..0000000 Binary files a/charging/ipmininet/topologies/__pycache__/ConfigTopo.cpython-310.pyc and /dev/null differ diff --git a/charging/ipmininet/topologies/__pycache__/ConfigTopo.cpython-312.pyc b/charging/ipmininet/topologies/__pycache__/ConfigTopo.cpython-312.pyc deleted file mode 100644 index 4832c41..0000000 Binary files a/charging/ipmininet/topologies/__pycache__/ConfigTopo.cpython-312.pyc and /dev/null differ diff --git a/charging/ipmininet/topologies/__pycache__/SimpleTopo.cpython-310.pyc b/charging/ipmininet/topologies/__pycache__/SimpleTopo.cpython-310.pyc deleted file mode 100644 index a69e509..0000000 Binary files a/charging/ipmininet/topologies/__pycache__/SimpleTopo.cpython-310.pyc and /dev/null differ diff --git a/charging/ipmininet/topologies/__pycache__/__init__.cpython-310.pyc b/charging/ipmininet/topologies/__pycache__/__init__.cpython-310.pyc deleted file mode 100644 index 91ba121..0000000 Binary files a/charging/ipmininet/topologies/__pycache__/__init__.cpython-310.pyc and /dev/null differ diff --git a/charging/ipmininet/topologies/__pycache__/__init__.cpython-312.pyc b/charging/ipmininet/topologies/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index 370286d..0000000 Binary files a/charging/ipmininet/topologies/__pycache__/__init__.cpython-312.pyc and /dev/null differ diff --git a/charging/ipmininet/topologies/__pycache__/customHosts.cpython-310.pyc b/charging/ipmininet/topologies/__pycache__/customHosts.cpython-310.pyc deleted file mode 100644 index 5bb0fa6..0000000 Binary files a/charging/ipmininet/topologies/__pycache__/customHosts.cpython-310.pyc and /dev/null differ diff --git a/charging/ipmininet/topologies/__pycache__/customHosts.cpython-312.pyc b/charging/ipmininet/topologies/__pycache__/customHosts.cpython-312.pyc deleted file mode 100644 index 178ec7c..0000000 Binary files a/charging/ipmininet/topologies/__pycache__/customHosts.cpython-312.pyc and /dev/null differ diff --git a/charging/ipmininet/topologies/customTopo_config.yaml b/charging/ipmininet/topologies/customTopo_config.yaml index 625f5a9..185dbe8 100644 --- a/charging/ipmininet/topologies/customTopo_config.yaml +++ b/charging/ipmininet/topologies/customTopo_config.yaml @@ -1,6 +1,6 @@ clients: client0: - SecProfile: 2 + SecProfile: '2' attempts: 2 dns: DNS1 name: CLI0 @@ -43,12 +43,6 @@ routers: name: R0 router1: name: R1 - routerT: - name: RT - routerTe: - name: RTe - routerTes: - name: RTes servers: server0: dns: DNS1 diff --git a/charging/scenarios/charge_normally.py b/charging/scenarios/charge_normally.py index b1574cd..d85063a 100644 --- a/charging/scenarios/charge_normally.py +++ b/charging/scenarios/charge_normally.py @@ -18,7 +18,7 @@ except yaml.YAMLError as e: print('Failed to parse server_config.yaml') -from charging.client import launch_client, ChargePointClientBase, wait_for_button_press +from charging.client import launch_client, ChargePointClientBase, wait_for_button_press, load_config, CONFIGURATION logging.basicConfig(level=logging.ERROR) @@ -43,7 +43,7 @@ async def charge_normally(cp: ChargePointClientBase): await wait_for_button_press('AUTHORIZATION') # Send authorization request - response = await cp.send_authorize({'type': 'ISO15693', 'id_token': RFID_TOKEN}) + response = await cp.send_authorize({'type': TOKEN_TYPE, 'id_token': RFID_TOKEN }) # Check if authorization was accepted if response.id_token_info['status'] != "Accepted": @@ -93,10 +93,11 @@ async def charge_normally(cp: ChargePointClientBase): config = { 'vendor_name': 'EmuOCPPCharge', 'model': 'E2507', - 'serial_number': 'E2507-8420-1274', - 'password': 'HPEufO4u3IMl1G', - 'server': "[fe80::e3a6:46e4:bff9:fb8e%ens33]", - 'port': 9000 - } - + 'index':1 + } + + # Load config file + if not load_config(): + quit(1) + asyncio.run(launch_client(**config, async_runnable=charge_normally)) diff --git a/charging/scenarios/client_config.yaml b/charging/scenarios/client_config.yaml new file mode 100644 index 0000000..8033c9a --- /dev/null +++ b/charging/scenarios/client_config.yaml @@ -0,0 +1,47 @@ +HeartbeatInterval: 10 +comm: + HeartbeatInterval: 10 + MessageTimeout: 30 + NetworkConfigurationPriority: + - 0 + - 1 + - 2 + NetworkProfileConnectionAttempts: 2 + OfflineThreshold: 30 +ip: fe80::20c:29ff:fe0a:aa2b%ens160 +model: E2507 +port0: 9000 +port1: 9001 +port2: 9002 +port3: 9003 +port4: 9004 +port5: 9005 +port6: 9006 +port7: 9007 +profiles: + 0: + SP: 1 + ip: fe80::20c:29ff:fe0a:aa2b%ens160 + message_timeout: 30 + ocpp_version: OCPP201 + 1: + SP: 2 + ip: fe80::20c:29ff:fe0a:aa2b%ens160 + message_timeout: 30 + ocpp_version: OCPP201 + 2: + SP: 3 + ip: fe80::20c:29ff:fe0a:aa2b%ens160 + message_timeout: 30 + ocpp_version: OCPP201 +security: + AdditionalRootCertificateCheck: false + BasicAuthPassword: 48504575664f347533494d6c3147 + CertSigningRepeatTimes: 2 + CertSigningWaitMinimum: 30 + Identity: E2507-8420-1275 + OrganizationName: EmuOCPP + SecurityProfile: 1 +url: null +vendor_name: EmuOCPPCharge +version: v2.0.1 \ No newline at end of file diff --git a/charging/seed_db.py b/charging/seed_db.py new file mode 100644 index 0000000..17de484 --- /dev/null +++ b/charging/seed_db.py @@ -0,0 +1,41 @@ +import db + +def seed_users(): + print("[*] Adding dummy users...") + users = [ + ("E2507-8420-1275","48504575664f347533494d6c3147"), + ("E2507-8420-1274","HPEufO4u3IMl1G"), + ("charger_01", "pass123"), + ("charger_02", "pass456"), + ("admin", "admin"), + ] + for user, pwd in users: + try: + db.add_user(user, pwd) + print(f" [+] Added user: {user}") + except Exception as e: + print(f" [!] Skipped {user}: {e}") + +def seed_events(): + print("[*] Adding dummy events...") + events = [ + ("BootNotification", "charger_01", {"status": "Accepted"}), + ("Authorize", "charger_02", {"idTag": "ABC123"}), + ("Heartbeat", "charger_01", {"interval": 300}), + ] + for evt_type, target, data in events: + try: + db.add_event(evt_type, target, data) + print(f" [+] Added event: {evt_type} for {target}") + except Exception as e: + print(f" [!] Failed to add event: {e}") + +def main(): + print("⚡ Seeding database with dummy data...") + db.purge_events() + seed_users() + #seed_events() + print("✅ Done! Database is ready.") + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/charging/server.py b/charging/server.py index 45d17ee..99ef662 100644 --- a/charging/server.py +++ b/charging/server.py @@ -236,7 +236,7 @@ def load_config() -> bool: return True -def load_address(interface:str = 'ens33'): +def load_address(interface:str): try: addrs = netifaces.ifaddresses(interface) return addrs[netifaces.AF_INET6][0]['addr'] @@ -1012,7 +1012,7 @@ def load_certificate(cert_path): # Read the certificate from the file with open(cert_path, 'r') as cert_file: cert_data = cert_file.read() - # Ensure the certificate length is within the allowed bounds + # Ensure the certificate length is within the allowed bounds if len(cert_data) > 5500: raise ValueError("Certificate exceeds maximum allowed length (5500 characters).") return cert_data diff --git a/charging/server_config.yaml b/charging/server_config.yaml index 8f7ee45..0893511 100644 --- a/charging/server_config.yaml +++ b/charging/server_config.yaml @@ -13,7 +13,7 @@ accepted_tokens: - id_token: '1122334455667788' type: ISO15693 dns: null -ip: fe80::e3a6:46e4:bff9:fb8e%ens33 +ip: fc00:0:3::1%ens160 port0: 9000 port1: 9001 port2: 9002 diff --git a/DNS-flood-example.txt b/mitm/DNS-flood-example.txt similarity index 100% rename from DNS-flood-example.txt rename to mitm/DNS-flood-example.txt diff --git a/mitm/SimpleMitM.py b/mitm/SimpleMitM.py index 463034a..1d3b32e 100644 --- a/mitm/SimpleMitM.py +++ b/mitm/SimpleMitM.py @@ -49,13 +49,13 @@ def build(self, *args, **kwargs): # Open xterm for each host input('Press any key to launch server, CSO and client...') - makeTerm(h3, title= 'Server',cmd="bash -c './venv/bin/python3 ./charging/server.py -iface h3-eth0; exec bash'") + makeTerm(h3, title= 'Server',cmd="bash -c './venv/bin/python3 ./charging/server.py -iface h3-eth0 -config_file './mitm/server_config.yaml'; exec bash'") #fc00:0:1::1 makeTerm(h4, title= 'CSO',cmd=f"bash -c 'echo Loading...; sleep 30; ./venv/bin/python3 ./charging/cso.py -server {h3.defaultIntf().ip6}; exec bash'") - makeTerm(h1, title= 'Client',cmd=F"bash -c 'echo Loading...; sleep 30; ./venv/bin/python3 ./charging/client.py -server {h3.defaultIntf().ip6}; exec bash'") + makeTerm(h1, title= 'Client',cmd=F"bash -c 'echo Loading...; sleep 30; ./venv/bin/python3 ./charging/client.py -server {h3.defaultIntf().ip6} -config_file './mitm/client_config.yaml'; exec bash'") input('Press any key to launch attacker phase 1 when the CP is connected with the CSMS...') - makeTerm(h2, title= 'NDP Spoof',cmd="bash -c 'bash ./mitm/prep.sh; parasite6 -l h2-eth0; exec bash'") - makeTerm(h2, title= 'Flood network',cmd="bash -c 'flood_router26 h2-eth0; exec bash'") + makeTerm(h2, title= 'NDP Spoof',cmd="bash -c 'bash ./mitm/prep.sh; atk6-parasite6 -l h2-eth0; exec bash'") + makeTerm(h2, title= 'Flood network',cmd="bash -c 'atk6-flood_router26 h2-eth0; exec bash'") input('Press any key to launch attacker phase 2 when address spoofed and flood terminal is closed...') makeTerm(h2, cmd=f"echo Trying to disconnect the CP from the CSMS...; echo 0 > /proc/sys/net/ipv6/conf/all/forwarding; sleep {BLOCKING_TIME}; echo 1 > /proc/sys/net/ipv6/conf/all/forwarding") diff --git a/mitm/__pycache__/downgrade.cpython-310.pyc b/mitm/__pycache__/downgrade.cpython-310.pyc deleted file mode 100644 index f9bf5e0..0000000 Binary files a/mitm/__pycache__/downgrade.cpython-310.pyc and /dev/null differ diff --git a/mitm/__pycache__/mitm.cpython-310.pyc b/mitm/__pycache__/mitm.cpython-310.pyc deleted file mode 100644 index 4eb33fc..0000000 Binary files a/mitm/__pycache__/mitm.cpython-310.pyc and /dev/null differ diff --git a/mitm/__pycache__/mitm.cpython-312.pyc b/mitm/__pycache__/mitm.cpython-312.pyc deleted file mode 100644 index 2d907f6..0000000 Binary files a/mitm/__pycache__/mitm.cpython-312.pyc and /dev/null differ diff --git a/mitm/client_config.yaml b/mitm/client_config.yaml new file mode 100644 index 0000000..a464874 --- /dev/null +++ b/mitm/client_config.yaml @@ -0,0 +1,47 @@ +HeartbeatInterval: 10 +comm: + HeartbeatInterval: 10 + MessageTimeout: 30 + NetworkConfigurationPriority: + - 0 + - 1 + - 2 + NetworkProfileConnectionAttempts: 2 + OfflineThreshold: 30 +ip: fc00:0:1::1 +model: E2507 +port0: 9000 +port1: 9001 +port2: 9002 +port3: 9003 +port4: 9004 +port5: 9005 +port6: 9006 +port7: 9007 +profiles: + 0: + SP: 1 + ip: fc00:0:1::1 + message_timeout: 30 + ocpp_version: OCPP201 + 1: + SP: 2 + ip: fc00:0:1::1 + message_timeout: 30 + ocpp_version: OCPP201 + 2: + SP: 3 + ip: fc00:0:1::1 + message_timeout: 30 + ocpp_version: OCPP201 +security: + AdditionalRootCertificateCheck: false + BasicAuthPassword: HPEufO4u3IMl1G + CertSigningRepeatTimes: 2 + CertSigningWaitMinimum: 30 + Identity: E2507-8420-1274 + OrganizationName: EmuOCPP + SecurityProfile: 1 +url: null +vendor_name: EmuOCPPCharge +version: v2.0.1 diff --git a/flood.sh b/mitm/flood.sh similarity index 100% rename from flood.sh rename to mitm/flood.sh diff --git a/mitm/mitm.py b/mitm/mitm.py index e1f1564..e4a431c 100644 --- a/mitm/mitm.py +++ b/mitm/mitm.py @@ -75,7 +75,7 @@ def print_dict(d, indent = 0, msg = None): if key == 'certificateChain' or key == 'cert': print("====================================================\n") print("====================================================\n") - print(" DROPING MESSAGE \n") + print(" DROPPING MESSAGE \n") print("====================================================\n") print("====================================================\n") msg.drop() diff --git a/mitm/server_config.yaml b/mitm/server_config.yaml new file mode 100644 index 0000000..3e86d62 --- /dev/null +++ b/mitm/server_config.yaml @@ -0,0 +1,29 @@ +accepted_chargers: +- model: E2507 + serial_number_regex: ^E2507-[0-9]{4}-[0-9]{4}$ + vendor_name: EmuOCPPCharge +- model: E2508 + serial_number_regex: ^E2508-[0-9]{4}-[0-9]{4}$ + vendor_name: EmuOCPPCharge +accepted_tokens: +- id_token: '11223344' + type: ISO14443 +- id_token: '11223344556677' + type: ISO14443 +- id_token: '1122334455667788' + type: ISO15693 +dns: null +ip: fc00:0:1::1 +port0: 9000 +port1: 9001 +port2: 9002 +port3: 9003 +port4: 9004 +port5: 9005 +port6: 9006 +port7: 9007 +security: + allow_multiple_serial_numbers: 2 + heartbeat_interval: 10 + max_connected_clients: 100000 +url: null diff --git a/scripts/install.sh b/scripts/install.sh index c98103b..fe39fec 100644 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -1,5 +1,10 @@ #!/bin/sh +sudo apt update +sudo apt install frr frr-pythontools +sudo apt install bridge-utils +export PATH=$PATH:/usr/lib/frr + python3 -m venv "$(dirname "$0")"/../venv "$(dirname "$0")"/../venv/bin/pip install -r "$(dirname "$0")"/../requirements.txt -"$(dirname "$0")"/../venv/bin/pip install ipmininet --no-deps +"$(dirname "$0")"/../venv/bin/pip install --upgrade git+https://github.com/cnp3/ipmininet.git@v1.1