早上好,我想通过esp8266发送数据,我在byethost有一个合格帐户,我还有一个托管帐户与另一个托管服务提供商付款,但是通过byethost我收到以下错误:
AT+CIPSTART="TCP","ahorrodeenergy.byethost17.com",80
AT+CIPSEND=67
GET /inserta.php HTTP/1.1
Host:ahorrodeenergy.byethost17.com/inserta.php"
+IPD,1080:HTTP/1.1 200 OK
Server: nginx
Date: Fri, 10 Mar 2017 01:30:09 GMT
Content-Type: text/html
Content-Length: 851
Connection: keep-alive
Vary: Accept-Encoding
Expires: THu, 01 Jan 1970 00:00:01 GMT
Cache-Control: no-cache
并返回:此网站需要Javascript才能运行,请在您的浏览器中启用Javascript或使用支持Javascript的浏览器
答案 0 :(得分:0)
欺骗User-Agent字符串。它可能会尝试通过它来识别您的浏览器,然后尝试确定您是否启用了JavaScript。然后,它可以尝试使用更多活动测试,例如插入一段JavaScript并期望以挑战和响应的方式调用该javascript计算结果的页面。但我认为用户代理欺骗应该可以正常工作。执行以下操作:
AT+CIPSTART="TCP","ahorrodeenergy.byethost17.com",80
AT+CIPSEND=154
GET /inserta.php HTTP/1.1
Host: ahorrodeenergy.byethost17.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:51.0) Gecko/20100101 Firefox/51.0
+IPD,1080: ..
(CIPSEND中的数字假定\r\n
被用作换行符)
答案 1 :(得分:-2)
根据this awnser,问题是testcookie-nginx-module由byethost使用,此处为解决方案:
/*
Author: Moien007
Source: https://gist.github.com/moien007/06656aa4032c45b629a507dd4dcb6fd6
Description:
Bypass testcookie-nginx-module bot protection
Web host providers like Byethost uses that module so...
*/
using System;
using System.Linq;
using System.Threading.Tasks;
using System.Security.Cryptography;
using System.Net;
using System.Net.Http;
namespace Gist
{
class CustomWebClient
{
const string TestCookieSign = "aes.js";
public static byte[] Get(string url)
{
var address = new Uri(url);
var cookieContainer = new CookieContainer();
using (var handler = new HttpClientHandler() { CookieContainer = cookieContainer })
using (var client = new HttpClient(handler))
{
var content = client.GetAsync(address).WaitResult().Content;
var script = content.ReadAsStringAsync().WaitResult();
if (!script.Contains(TestCookieSign))
{
return content.ReadAsByteArrayAsync().WaitResult();
}
var test = Decrypt(script);
cookieContainer.Add(new Cookie("__test", test) { Domain = address.Host });
content = client.GetAsync(address).WaitResult().Content;
if (content.ReadAsStringAsync().WaitResult().Contains(TestCookieSign))
{
throw new Exception();
}
return content.ReadAsByteArrayAsync().WaitResult();
}
}
public static byte[] Post(string url, byte[] data)
{
var address = new Uri(url);
var cookieContainer = new CookieContainer();
using (var handler = new HttpClientHandler() { CookieContainer = cookieContainer })
using (var client = new HttpClient(handler))
using (var post = new ByteArrayContent(data))
{
var content = client.PostAsync(address, post).WaitResult().Content;
var script = content.ReadAsStringAsync().WaitResult();
if (!script.Contains(TestCookieSign))
{
return content.ReadAsByteArrayAsync().WaitResult();
}
var test = Decrypt(script);
cookieContainer.Add(new Cookie("__test", test) { Domain = address.Host });
content = client.PostAsync(address, post).WaitResult().Content;
if (content.ReadAsStringAsync().WaitResult().Contains(TestCookieSign))
{
throw new Exception();
}
return content.ReadAsByteArrayAsync().WaitResult();
}
}
static string Decrypt(string script)
{
var split = script.Split(new[] { "toNumbers(\"", "\")" }, StringSplitOptions.RemoveEmptyEntries)
.Where(s => s.Length == 32)
.ToArray();
if (split.Length != 3)
throw new Exception();
var key = StringToByteArray(split[0]);
var iv = StringToByteArray(split[1]);
var bytesIn = StringToByteArray(split[2]);
var aes = Aes.Create();
aes.Padding = PaddingMode.None;
aes.Mode = CipherMode.CBC;
aes.BlockSize = 128;
aes.KeySize = 128;
aes.Key = key;
aes.IV = iv;
var decrypter = aes.CreateDecryptor();
var decrypted = decrypter.TransformFinalBlock(bytesIn, 0, bytesIn.Length);
decrypter.Dispose();
aes.Dispose();
return BitConverter.ToString(decrypted).Replace("-", "").ToLower();
}
static byte[] StringToByteArray(string hex) // Taken from https://stackoverflow.com/a/321404/9248173
{
return Enumerable.Range(0, hex.Length)
.Where(x => x % 2 == 0)
.Select(x => Convert.ToByte(hex.Substring(x, 2), 16))
.ToArray();
}
}
static class ExtensionMethods
{
public static T WaitResult<T>(this Task<T> task)
{
task.Wait();
return task.Result;
}
}
}