#!/usr/bin/env python3 import requests # User vars ont_host = "192.168.18.1" ont_username = USERNAME ont_password = BASE64PASS # Build URL prefix ont_urlprefix = "http://" + ont_host # Start http session ont_session = requests.Session() # Get sid req = ont_session.post(ont_urlprefix + "/asp/GetRandCount.asp") sid = req.text[-32:] # Session authentication auth_data = {"UserName": ont_username, "PassWord": ont_password, "x.X_HW_Token": sid} req = ont_session.post(ont_urlprefix + "/login.cgi", data=auth_data) # Retrieve info req = ont_session.get(ont_urlprefix + "/html/amp/opticinfo/opticinfo.asp") print(req.text) # Logout ont_session.post(ont_urlprefix + "/logout.cgi?RequestFile=html/logout.html") exit(0) #### #!/usr/bin/perl use strict; use warnings; use LWP::UserAgent; use HTTP::Request::Common; # User vars my $ont_host = "192.168.18.1"; my $ont_username = USERNAME; my $ont_password = BASE64PASS; # Build URL prefix my $url = "http://" . $ont_host; # Start http session my $ua = LWP::UserAgent->new(keep_alive => 1); # Get sid my $res = $ua->post($url . '/asp/GetRandCount.asp'); my $sid = $res->content; # Session authentication $res = $ua->post($url . '/login.cgi', [UserName => "$ont_username", PassWord => "$ont_password", 'x.X_HW_Token' => "$sid"]); # Retrieve info $res = $ua->get($url . '/html/amp/opticinfo/opticinfo.asp'); print($res->content); $res = $ua->get($url . '/logout.cgi?RequestFile=html/logout.html'); #### root@HERMES:~$ tcpdump -ttnnvvS 'tcp and net 192.168.18.0/24' tcpdump: listening on ethwan, link-type EN10MB (Ethernet), capture size 262144 bytes 1612530239.807502 IP (tos 0x0, ttl 63, id 6338, offset 0, flags [DF], proto TCP (6), length 52) 192.168.18.2.54798 > 192.168.18.1.80: Flags [S], cksum 0xb418 (correct), seq 4024652913, win 64240, options [mss 1460,nop,nop,sackOK,nop,wscale 7], length 0 1612530239.808064 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 52) 192.168.18.1.80 > 192.168.18.2.54798: Flags [S.], cksum 0x90f7 (correct), seq 1577355000, ack 4024652914, win 14600, options [mss 1460,nop,nop,sackOK,nop,wscale 3], length 0 1612530239.808814 IP (tos 0x0, ttl 63, id 6339, offset 0, flags [DF], proto TCP (6), length 40) 192.168.18.2.54798 > 192.168.18.1.80: Flags [.], cksum 0x08d8 (correct), seq 4024652914, ack 1577355001, win 502, length 0 1612530239.808876 IP (tos 0x0, ttl 63, id 6340, offset 0, flags [DF], proto TCP (6), length 223) 192.168.18.2.54798 > 192.168.18.1.80: Flags [P.], cksum 0x7f17 (correct), seq 4024652914:4024653097, ack 1577355001, win 502, length 183: HTTP, length: 183 POST /asp/GetRandCount.asp HTTP/1.1 Host: 192.168.18.1 User-Agent: python-requests/2.25.1 Accept-Encoding: gzip, deflate Accept: */* Connection: keep-alive Content-Length: 0 1612530240.359236 IP (tos 0x0, ttl 64, id 26662, offset 0, flags [DF], proto TCP (6), length 522) 192.168.18.1.80 > 192.168.18.2.54798: Flags [FP.], cksum 0xa1b0 (correct), seq 1577390430:1577390912, ack 4024653989, win 2361, length 482: HTTP 1612530240.361735 IP (tos 0x0, ttl 63, id 6369, offset 0, flags [DF], proto TCP (6), length 40) 192.168.18.2.54798 > 192.168.18.1.80: Flags [.], cksum 0x785d (correct), seq 4024653989, ack 1577390913, win 501, length 0 1612530240.390570 IP (tos 0x0, ttl 63, id 6370, offset 0, flags [DF], proto TCP (6), length 40) 192.168.18.2.54798 > 192.168.18.1.80: Flags [F.], cksum 0x785c (correct), seq 4024653989, ack 1577390913, win 501, length 0 1612530240.391007 IP (tos 0x0, ttl 64, id 21626, offset 0, flags [DF], proto TCP (6), length 40) 192.168.18.1.80 > 192.168.18.2.54798: Flags [.], cksum 0x7118 (correct), seq 1577390913, ack 4024653990, win 2361, length 0 ^C 8 packets captured 8 packets received by filter 0 packets dropped by kernel #### root@HERMES:~$ tcpdump -ttnnvvS 'tcp and net 192.168.18.0/24' tcpdump: listening on ethwan, link-type EN10MB (Ethernet), capture size 262144 bytes 1612532228.397661 IP (tos 0x0, ttl 63, id 13929, offset 0, flags [DF], proto TCP (6), length 52) 192.168.18.2.54818 > 192.168.18.1.80: Flags [S], cksum 0xe5dc (correct), seq 3899533838, win 64240, options [mss 1460,nop,nop,sackOK,nop,wscale 7], length 0 1612532228.398192 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 52) 192.168.18.1.80 > 192.168.18.2.54818: Flags [S.], cksum 0x6b28 (correct), seq 3067119039, ack 3899533839, win 14600, options [mss 1460,nop,nop,sackOK,nop,wscale 3], length 0 1612532228.398911 IP (tos 0x0, ttl 63, id 13930, offset 0, flags [DF], proto TCP (6), length 40) 192.168.18.2.54818 > 192.168.18.1.80: Flags [.], cksum 0xe308 (correct), seq 3899533839, ack 3067119040, win 502, length 0 1612532228.591851 IP (tos 0x0, ttl 64, id 27663, offset 0, flags [DF], proto TCP (6), length 507) 192.168.18.1.80 > 192.168.18.2.54818: Flags [FP.], cksum 0x52f1 (correct), seq 3067119452:3067119919, ack 3899534340, win 2093, length 467: HTTP 1612532228.596974 IP (tos 0x0, ttl 63, id 13936, offset 0, flags [DF], proto TCP (6), length 40) 192.168.18.2.54818 > 192.168.18.1.80: Flags [F.], cksum 0xdda3 (correct), seq 3899534340, ack 3067119920, win 501, length 0 1612532228.597411 IP (tos 0x0, ttl 64, id 27664, offset 0, flags [DF], proto TCP (6), length 40) 192.168.18.1.80 > 192.168.18.2.54818: Flags [.], cksum 0xd76b (correct), seq 3067119920, ack 3899534341, win 2093, length 0 1612532228.598786 IP (tos 0x0, ttl 63, id 64322, offset 0, flags [DF], proto TCP (6), length 52) 192.168.18.2.54820 > 192.168.18.1.80: Flags [S], cksum 0x7b93 (correct), seq 4176643025, win 64240, options [mss 1460,nop,nop,sackOK,nop,wscale 7], length 0 1612532228.599223 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 52) 192.168.18.1.80 > 192.168.18.2.54820: Flags [S.], cksum 0x7611 (correct), seq 274904827, ack 4176643026, win 14600, options [mss 1460,nop,nop,sackOK,nop,wscale 3], length 0 1612532228.599942 IP (tos 0x0, ttl 63, id 64323, offset 0, flags [DF], proto TCP (6), length 40) 192.168.18.2.54820 > 192.168.18.1.80: Flags [.], cksum 0xedf1 (correct), seq 4176643026, ack 274904828, win 502, length 0 1612532228.604128 IP (tos 0x0, ttl 64, id 24356, offset 0, flags [DF], proto TCP (6), length 507) 192.168.18.1.80 > 192.168.18.2.54820: Flags [FP.], cksum 0x6117 (correct), seq 274905011:274905478, ack 4176643195, win 1825, length 467: HTTP 1612532228.604628 IP (tos 0x0, ttl 64, id 24357, offset 0, flags [DF], proto TCP (6), length 40) 192.168.18.1.80 > 192.168.18.2.54820: Flags [R.], cksum 0xe58e (correct), seq 274905479, ack 4176643195, win 1825, length 0 1612532228.611532 IP (tos 0x0, ttl 63, id 44109, offset 0, flags [DF], proto TCP (6), length 52) 192.168.18.2.54822 > 192.168.18.1.80: Flags [S], cksum 0x3645 (correct), seq 3432379770, win 64240, options [mss 1460,nop,nop,sackOK,nop,wscale 7], length 0 1612532228.612001 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 52) 192.168.18.1.80 > 192.168.18.2.54822: Flags [S.], cksum 0xd064 (correct), seq 2196415697, ack 3432379771, win 14600, options [mss 1460,nop,nop,sackOK,nop,wscale 3], length 0 1612532228.612563 IP (tos 0x0, ttl 63, id 44110, offset 0, flags [DF], proto TCP (6), length 40) 192.168.18.2.54822 > 192.168.18.1.80: Flags [.], cksum 0x4845 (correct), seq 3432379771, ack 2196415698, win 502, length 0 1612532228.618717 IP (tos 0x0, ttl 64, id 19728, offset 0, flags [DF], proto TCP (6), length 40) 192.168.18.1.80 > 192.168.18.2.54822: Flags [F.], cksum 0x3f59 (correct), seq 2196416348, ack 3432379947, win 1959, length 0 1612532228.618842 IP (tos 0x0, ttl 63, id 44113, offset 0, flags [DF], proto TCP (6), length 40) 192.168.18.2.54822 > 192.168.18.1.80: Flags [.], cksum 0x450c (correct), seq 3432379947, ack 2196416348, win 501, length 0 1612532228.618873 IP (tos 0x0, ttl 64, id 19729, offset 0, flags [DF], proto TCP (6), length 40) 192.168.18.1.80 > 192.168.18.2.54822: Flags [R.], cksum 0x3f55 (correct), seq 2196416349, ack 3432379947, win 1959, length 0 1612532228.619373 IP (tos 0x0, ttl 64, id 54882, offset 0, flags [DF], proto TCP (6), length 40) 192.168.18.1.80 > 192.168.18.2.54822: Flags [R], cksum 0x09cf (correct), seq 2196416348, win 0, length 0 ^C 18 packets captured 18 packets received by filter 0 packets dropped by kernel