Skip to content

Commit 1fff7b0

Browse files
Add files via upload
1 parent bf611f8 commit 1fff7b0

File tree

4 files changed

+237
-0
lines changed

4 files changed

+237
-0
lines changed

README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Proxy Checker
2+
3+
Simple **HTTP/HTTPS** proxy checker written with Python and push all good proxies to MYSQL DB
4+
5+
# Newly Added
6+
7+
### you can save all good proxies to SQL DB with the MySqlDB library. import .sql file to PHPMyAdmin and start the program
8+
9+
# Usage
10+
11+
## Get started
12+
13+
First, you need to get rid of problems with executing permissions, so to do that, open the terminal and say:
14+
15+
```bash
16+
chmod +x prox.py
17+
```
18+
### Setup MySQL file to phpmyadmin and setup password and user to MySqlDB
19+
20+
```
21+
--
22+
-- Table structure for table `proxy`
23+
--
24+
25+
CREATE TABLE `proxy` (
26+
`id` int(4) NOT NULL,
27+
`proxy` text NOT NULL,
28+
`checked_time_input` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
29+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
30+
31+
```
32+
33+
### setup your localhost, password and user in mysql/phpmyadmin
34+
35+
```
36+
mydb = MySQLdb.connect(host='localhost',
37+
user='',
38+
passwd='',
39+
db='proxy')
40+
cursor = mydb.cursor()
41+
```
42+
43+
### Check proxies from a file
44+
45+
```bash
46+
./prox.py -f <FILENAME>
47+
```
48+
49+
### Check only one proxy
50+
51+
```bash
52+
./prox.py -p <IP:PORT>
53+
```
54+

prox.py

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
#!/usr/bin/python3
2+
3+
'''
4+
PROX - utility for checking proxy in terminal under the GNU GPL V3.0 Licensy
5+
AUTHORS: Hasanov Abdurahmon & Ilyosiddin Kalandar, MySql Part Created By Pasan Laksitha
6+
Version: 0.3 with MySql You can check Main Edition from GitHub:-pythonism
7+
'''
8+
9+
from sys import argv
10+
import urllib3
11+
from os import system as terminal
12+
import requests
13+
from colorama import Fore,Style
14+
import MySQLdb
15+
16+
URL = "http://google.com"
17+
CMD_CLEAR_TERM = "clear"
18+
TIMEOUT = (3.05,27)
19+
db_commits = 0
20+
21+
mydb = MySQLdb.connect(host='localhost',
22+
user='',
23+
passwd='',
24+
db='proxy')
25+
cursor = mydb.cursor()
26+
27+
def check_proxy(proxy):
28+
'''
29+
Function for check proxy return ERROR
30+
if proxy is Bad else
31+
Function return None
32+
'''
33+
try:
34+
session = requests.Session()
35+
session.headers['User-Agent'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.131 Safari/537.36'
36+
session.max_redirects = 300
37+
proxy = proxy.split('\n',1)[0]
38+
print(Fore.LIGHTYELLOW_EX + 'Checking ' + proxy)
39+
session.get(URL, proxies={'http':'http://' + proxy}, timeout=TIMEOUT,allow_redirects=True)
40+
except requests.exceptions.ConnectionError as e:
41+
print(Fore.LIGHTRED_EX + 'Error!')
42+
return e
43+
except requests.exceptions.ConnectTimeout as e:
44+
print(Fore.LIGHTRED_EX + 'Error,Timeout!')
45+
return e
46+
except requests.exceptions.HTTPError as e:
47+
print(Fore.LIGHTRED_EX + 'HTTP ERROR!')
48+
return e
49+
except requests.exceptions.Timeout as e:
50+
print(Fore.LIGHTRED_EX + 'Error! Connection Timeout!')
51+
return e
52+
except urllib3.exceptions.ProxySchemeUnknown as e:
53+
print(Fore.LIGHTRED_EX + 'ERROR unkown Proxy Scheme!')
54+
return e
55+
except requests.exceptions.TooManyRedirects as e:
56+
print(Fore.LIGHTRED_EX + 'ERROR! Too many redirects!')
57+
return e
58+
def print_help():
59+
terminal(CMD_CLEAR_TERM)
60+
print(Fore.LIGHTGREEN_EX + 'PROX v0.2 - Utility for checking proxy in terminal')
61+
print(Fore.LIGHTGREEN_EX + 'Authors: Hasanov Abdurahmon & Ilyosiddin Kalandar, MySql Part Created By Pasan Laksitha')
62+
print(Fore.LIGHTCYAN_EX)
63+
print('Usage -> prox -f <filename> - Check file with proxies')
64+
print('prox -p <proxy> - check only one proxy')
65+
print('prox --help - show this menu')
66+
67+
if len(argv) > 1:
68+
commands = ['--help','-h','-f','-p','/?','--file','-file','--proxy','-proxy']
69+
if argv[1] in commands:
70+
if argv[1] in ('--help','-help','/?','--?'):
71+
print_help()
72+
elif argv[1] in ('-f','--file','-file'):
73+
try:
74+
file = open(argv[2])
75+
proxies = list(file)
76+
goods = 0
77+
terminal(CMD_CLEAR_TERM)
78+
print(Fore.LIGHTCYAN_EX + '===========================================')
79+
for proxy in proxies:
80+
try:
81+
if check_proxy(proxy):
82+
print(Fore.LIGHTRED_EX + 'Bad proxy ' + proxy)
83+
else:
84+
print(Fore.LIGHTGREEN_EX + 'Good proxy ' + proxy)
85+
file_with_goods = open('good.txt','a')
86+
file_with_goods.write(proxy)
87+
goods += 1
88+
try:
89+
cursor.execute(f"INSERT INTO proxy (proxy) VALUES ('{proxy}');")
90+
mydb.commit()
91+
print("DB Commited")
92+
db_commits += 1
93+
except:
94+
print("DB NOT Commited")
95+
96+
print(Fore.LIGHTCYAN_EX + '=================================================')
97+
except KeyboardInterrupt:
98+
print(Fore.LIGHTGREEN_EX + '\nExit.')
99+
exit()
100+
print(Fore.LIGHTGREEN_EX + 'Total ' + str(goods) + ' good proxies found')
101+
print(Fore.LIGHTRED_EX + 'And ' + str(len(proxies) - goods) + ' is bad')
102+
print(Fore.LIGHTYELLOW_EX + 'Have nice day! :)')
103+
print()
104+
except FileNotFoundError:
105+
print(Fore.LIGHTRED_EX + 'Error!\nFile Not found!')
106+
except IndexError:
107+
print(Fore.LIGHTRED_EX + 'Error!\nMissing filename!')
108+
elif argv[1] in ('-p','--proxy','-proxy'):
109+
try:
110+
argv[2] = argv[2].split(' ')[0]
111+
if check_proxy(argv[2]):
112+
print(Fore.LIGHTRED_EX + 'BAD PROXY ' + argv[2])
113+
else:
114+
print(Fore.LIGHTGREEN_EX + 'GOOD PROXY ' + argv[2])
115+
try:
116+
cursor.execute(f"INSERT INTO proxy (proxy) VALUES ('{proxy}');")
117+
mydb.commit()
118+
print("DB Commited")
119+
db_commits += 1
120+
except:
121+
print("DB NOT Commited")
122+
except IndexError:
123+
print(Fore.LIGHTRED_EX + 'Error! Missing proxy!')
124+
else:
125+
print(Fore.LIGHTRED_EX + 'Unknown option \"' + argv[1] + '\"')
126+
else:
127+
print_help()

proxy.sql

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
2+
3+
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
4+
START TRANSACTION;
5+
SET time_zone = "+00:00";
6+
7+
8+
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
9+
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
10+
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
11+
/*!40101 SET NAMES utf8mb4 */;
12+
13+
--
14+
-- Database: `proxy`
15+
--
16+
17+
-- --------------------------------------------------------
18+
19+
--
20+
-- Table structure for table `proxy`
21+
--
22+
23+
CREATE TABLE `proxy` (
24+
`id` int(4) NOT NULL,
25+
`proxy` text NOT NULL,
26+
`country` text NOT NULL,
27+
`checked_time_input` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
28+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
29+
30+
--
31+
-- Indexes for dumped tables
32+
--
33+
34+
--
35+
-- Indexes for table `proxy`
36+
--
37+
ALTER TABLE `proxy`
38+
ADD PRIMARY KEY (`id`);
39+
40+
--
41+
-- AUTO_INCREMENT for dumped tables
42+
--
43+
44+
--
45+
-- AUTO_INCREMENT for table `proxy`
46+
--
47+
ALTER TABLE `proxy`
48+
MODIFY `id` int(4) NOT NULL AUTO_INCREMENT;
49+
COMMIT;
50+
51+
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
52+
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
53+
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
colorama
2+
requests
3+
MySQL-python

0 commit comments

Comments
 (0)