-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnote.txt
95 lines (84 loc) · 3.85 KB
/
note.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using System.IO;
using System.Net.Http;
namespace HackSagemRouter
{
class Program
{
static void Main(string[] args)
{
var sagemClient = new SagemClient();
sagemClient.Reboot();
Console.ReadLine();
}
public void UpdateViewHttpWebRequest()
{
// view - source:http://192.168.1.1/wlmacflt.cmd?action=view
// http://192.168.1.1/wlmacflt.cmd?wlmacflt.cmd?action=remove&rmLst=8:B1:DB:D7:AA:3D&sessionKey=154855720
var cookies = new CookieContainer();
HttpWebRequest request = RequestFactory("http://192.168.1.1/wlmacflt.cmd?action=view", cookies);
string sessionKey = string.Empty;
// Wil try to get a session key which will be used to remove mask
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
using (StreamReader responseReader = new StreamReader(response.GetResponseStream()))
{
string output = responseReader.ReadToEnd();
Console.WriteLine(output);
int idx = output.IndexOf("sessionKey=");
idx += nameof(sessionKey).Length + 1;
int endIdx = output.IndexOf("\"", idx);
sessionKey = output.Substring(idx, endIdx - idx);
}
request = RequestFactory("http://192.168.1.1/wlmacflt.cmd?wlmacflt.cmd?action=remove&rmLst=8:B1:DB:D7:AA:3D&sessionKey=" + sessionKey, cookies);
response = (HttpWebResponse)request.GetResponse();
using (StreamReader responseReader = new StreamReader(response.GetResponseStream()))
{
string output = responseReader.ReadToEnd();
Console.WriteLine(output);
}
Console.ReadLine();
//GET /wlmacflt.cmd?action=view HTTP/1.1
//Host: 192.168.1.1
//Connection: keep-alive
//Cache-Control: max-age=400
//Authorization: Basic YWRtaW46My4xNDE1
//Upgrade-Insecure-Requests: 1
//User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.59 Safari/537.36
//Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
//DNT: 1
//Accept-Encoding: gzip, deflate, sdch
//Accept-Language: en-US,en;q=0.8,pt;q=0.6
}
public static HttpWebRequest RequestFactory(string url, CookieContainer cookies)
{
var request = (HttpWebRequest)WebRequest.Create(url);
// Note: Working without cookies.
request.CookieContainer = cookies;
request.Method = "GET";
// Is this really neccesary for second call if we are using cookie? - Look like it is :D (tested)
request.Headers["Authorization"] = "Basic YWRtaW46My4xNDE1";
request.UserAgent = "Hack";
request.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip;
request.Accept = "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
return request;
// Google KeepAlive, Cache-Control http-header
}
}
}
You need dat cookie jar
{
CookieContainer cookies = new CookieContainer();
HttpClientHandler handler = new HttpClientHandler();
handler.CookieContainer = cookies;
HttpClient client = new HttpClient(handler);
HttpResponseMessage response = client.GetAsync("http://google.com").Result;
Uri uri = new Uri("http://google.com");
IEnumerable<Cookie> responseCookies = cookies.GetCookies(uri).Cast<Cookie>();
foreach (Cookie cookie in responseCookies)
Console.WriteLine(cookie.Name + ": " + cookie.Value);
}