network stuff...

Just starting out? Need help? Post your questions and find answers here.
ZX80
Enthusiast
Enthusiast
Posts: 361
Joined: Mon Dec 12, 2016 1:37 pm

network stuff...

Post by ZX80 »

Hello, all.

I have long been interested in one question, but I do not have enough knowledge or experience to at least understand how to approach it. As I am very far from networking technologies (different requests and their processing), I would be grateful for any help or hint in solving this issue. I assume I need a program like wireshark or something similar to capture network packets. Okay, I have it. I tried to track something down there, but a ton of information was thrown at me. I almost drowned in it. So I would also appreciate it if someone knows a simple user manual for this program. For kinders. For the youngest children who do not yet have teeth :) For children who can't eat solid food yet, but only semolina powder.
Of course I know there's filtering, but it's still very complicated for me. Maybe someone can at least tell me the algorithm for my actions in this case? That would be very helpful.

So...
The foreplay is over. Let's get down to task.

I have a TP-LINK router. My copmuter gets internet through it by wire (patchcord). I also occasionally connect to it via wi-fi (for example, by connecting a smartphone). But... I don't want wi-fi to work always, but only when I need it. It is inconvenient to go through the web interface every time and change the switch position. Hence the question: how can this be done by program?
Attention! I am interested in this method, not in telnet.

I have seen this code on this forum:

Code: Select all

Define.s UserName, Password, EncodedLogin, TicketString, FullResponse, ResponseCode, URLString
Define *Login, Running

If Not InitNetwork()
  Debug "Problem initializing the network! Program Ending"
  End 101
EndIf

NewMap Header.s()

Username = "admin"
Password = "admin"
*Login = UTF8(UserName + ":" + Password)
EncodedLogin = Base64Encoder(*Login, MemorySize(*Login) - 1)

Header("Authorization") = "Basic " + EncodedLogin
Header("Accept") = "application/xml"
Header("Content-Type") = "application/xml"
ForEach Header()
  Debug MapKey(Header()) + ": " + Header()
Next
Debug ""
Debug "---------------------------------------------------------------"
Debug ""
URLString = "192.168.0.1"

Running = HTTPRequest(#PB_HTTP_Get, URLString, "", 0, Header())
If Running
  FullResponse = HTTPInfo(Running, #PB_HTTP_Response)
  ResponseCode = HTTPInfo(Running, #PB_HTTP_StatusCode)
  FinishHTTP(Running)
  Debug "Running: " + Running
  Debug "Response Code: " + ResponseCode
  Debug "Response: " + FullResponse
EndIf
I get response code: 200
Also full response:

Code: Select all

<!DOCTYPE html> 
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<META http-equiv=Content-Type content="text/html; charset=utf-8" />
<META http-equiv=Pragma content=no-cache>
<META http-equiv=Expires content=0>

<!-- 
<link rel="stylesheet" href="../css/login.css" type="text/css" />
<link rel="stylesheet" href="../img/login/login.css" type="text/css" />
-->
<style type="text/css">
body{
    font-family:Arial, sans-serief;
    background-color:#FFFFFF;
    margin:0px;
    padding:0px;
}
div.loginBox
{
    /*display: block;*/
    position:relative;
    margin-top:10%;
    text-align:center;
}
.nd {
    display: none !important;
}
.noteDiv{
    color:gray;
    ...
It's all good. But what to do next? And how do I get to the switch I want?

Has anyone done this kind of thing before?
Thank you in advance for any feedback.
infratec
Always Here
Always Here
Posts: 7577
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: network stuff...

Post by infratec »

This is different from router to router.
So we need the full type of the used TP-Link router.

If you are able to login via http and not https you can capture the packets via wireshark.
You need the packet which is send after you press the button who submit the new setting.

There you will find the variables the values and the form name.
With this informations it should be possible to send the request also by a PB code.
infratec
Always Here
Always Here
Posts: 7577
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: network stuff...

Post by infratec »

Btw. it would be good to know the exact type of the router.
infratec
Always Here
Always Here
Posts: 7577
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: network stuff...

Post by infratec »

Maybe it is this page:

https://www.tp-link.com/us/user-guides/ ... ub-title-4

Then start wireshark, listen to "host 192.168.0.1 and port 80" and press the save button.
Marc56us
Addict
Addict
Posts: 1600
Joined: Sat Feb 08, 2014 3:26 pm

Re: network stuff...

Post by Marc56us »

I have a TP-LINK router. My copmuter gets internet through it by wire (patchcord). I also occasionally connect to it via wi-fi (for example, by connecting a smartphone). But... I don't want wi-fi to work always, but only when I need it. It is inconvenient to go through the web interface every time and change the switch position. Hence the question: how can this be done by program?
Attention! I am interested in this method, not in telnet.
If it's just to stop the wifi at night or on certain days, most routers have an internal schedule.

If it's to program it, just use the manufacturer's API. It's much easier than going from menu to menu by HTTP.

Last possibility: SNMP commands but we use them rather to query a hardware.

This depends on the router model and firmware version.
:wink:
ZX80
Enthusiast
Enthusiast
Posts: 361
Joined: Mon Dec 12, 2016 1:37 pm

Re: network stuff...

Post by ZX80 »

infratec and Marc56us, thank you very much for your replies.
infratec wrote: Wed Dec 14, 2022 12:02 am So we need the full type of the used TP-Link router.
tp-link

Name : AC750 Dual Band Wireless Router
Model: Archer C20

Firmware version: 0.9.1 0.1 v0001.0 Build 200528 Rel.57249n(5255)
Hardware version: Archer C20 v5 00000005
It is the same as here, but has three antennas and no usb.
infratec wrote: Wed Dec 14, 2022 12:02 am If you are able to login via http and not https you can capture the packets via wireshark.
Yes, it can be done via http. Because in the address bar of firefox I see a crossed out lock.
infratec wrote: Wed Dec 14, 2022 12:02 am You need the packet which is send after you press the button who submit the new setting.

There you will find the variables the values and the form name.
With this informations it should be possible to send the request also by a PB code.
Thank you, I understand, but it's hard to find.
I tried it this way:
Right after I started wireshark, I set this filter
TCP or UDP port 80 (HTTP): port 80
and then further filtered like this
ip.addr == 192.168.0.1 and (tcp.port == 80 || udp.port == 80)
infratec wrote: Wed Dec 14, 2022 12:10 am Maybe it is this page:
...
Yes, this form looks the same.
Thank you for your participation. I will try again later. Should I look for the code word 'submit' ?

---------------------------
Marc56us wrote: Wed Dec 14, 2022 7:12 am If it's just to stop the wifi at night or on certain days, most routers have an internal schedule.
No, the schedule option doesn't work for me, as it can happen completely randomly.
Marc56us wrote: Wed Dec 14, 2022 7:12 am If it's to program it, just use the manufacturer's API. It's much easier than going from menu to menu by HTTP.
Where can I find it? Maybe you have an example?
Marc56us wrote: Wed Dec 14, 2022 7:12 am Last possibility: SNMP commands but we use them rather to query a hardware.
Thanks, I didn't know about that.

P.S. Sorry I'm late in replying.
P.S.2 I want to switch 2.4 GHz.
Post Reply