Skip to content

This Repository is a collection of different ethical hacking tools and malware's for penetration testing and research purpose written in python, ruby, rust, c++, go and c.

Add files via upload

Abdul Wahab Junaidc2e39b4683e5
diff --git a/Python Tools/Opening and reading URLs(urllib)/count_words_file.py b/Python Tools/Opening and reading URLs(urllib)/count_words_file.py
new file mode 100644
index 0000000..6f9c06d
--- /dev/null
+++ b/Python Tools/Opening and reading URLs(urllib)/count_words_file.py
@@ -0,0 +1,19 @@
+#!/usr/bin/env python3
+
+import urllib.request
+import urllib.error
+
+def count_words_file(url):
+ try:
+ file_response = urllib.request.urlopen(url)
+ except urllib.error.URLError as error:
+ print('Exception', error)
+ print('reason', error.reason)
+ else:
+ content = file_response.read()
+ return len(content.split())
+
+
+print(count_words_file('https://www.gutenberg.org/cache/epub/2000/pg2000.txt'))
+
+count_words_file('https://not-exists.txt')
diff --git a/Python Tools/Opening and reading URLs(urllib)/get_emails_url_request.py b/Python Tools/Opening and reading URLs(urllib)/get_emails_url_request.py
new file mode 100644
index 0000000..ddfa94e
--- /dev/null
+++ b/Python Tools/Opening and reading URLs(urllib)/get_emails_url_request.py
@@ -0,0 +1,18 @@
+import urllib.request
+import re
+
+USER_AGENT = 'Mozilla/5.0 (Linux; Android 10) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.101 Mobile Safari/537.36'
+
+url = input("Enter url:http://")
+
+#https://www.packtpub.com/about/terms-and-conditions
+
+opener = urllib.request.build_opener()
+opener.addheaders = [('User-agent', USER_AGENT)]
+urllib.request.install_opener(opener)
+
+response = urllib.request.urlopen('http://'+url)
+html_content= response.read()
+pattern = re.compile("[-a-zA-Z0-9._]+[-a-zA-Z0-9._]+@[-a-zA-Z0-9_]+.[a-zA-Z0-9_.]+")
+mails = re.findall(pattern,str(html_content))
+print(mails)
diff --git a/Python Tools/Opening and reading URLs(urllib)/get_headers_response_request.py b/Python Tools/Opening and reading URLs(urllib)/get_headers_response_request.py
new file mode 100644
index 0000000..2416bd2
--- /dev/null
+++ b/Python Tools/Opening and reading URLs(urllib)/get_headers_response_request.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python3
+
+import urllib.request
+from urllib.request import Request
+
+url="http://awjunaid.com"
+USER_AGENT = 'Mozilla/5.0 (Linux; Android 10) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.101 Mobile Safari/537.36'
+
+def chrome_user_agent():
+ opener = urllib.request.build_opener()
+ opener.addheaders = [('User-agent', USER_AGENT)]
+ urllib.request.install_opener(opener)
+ response = urllib.request.urlopen(url)
+ print("Response headers")
+ print("--------------------")
+ for header,value in response.getheaders():
+ print(header + ":" + value)
+
+ request = Request(url)
+ request.add_header('User-agent', USER_AGENT)
+ print("\nRequest headers")
+ print("--------------------")
+ for header,value in request.header_items():
+ print(header + ":" + value)
+
+if __name__ == '__main__':
+ chrome_user_agent()
diff --git a/Python Tools/Opening and reading URLs(urllib)/json_response.py b/Python Tools/Opening and reading URLs(urllib)/json_response.py
new file mode 100644
index 0000000..5e44a28
--- /dev/null
+++ b/Python Tools/Opening and reading URLs(urllib)/json_response.py
@@ -0,0 +1,10 @@
+#!/usr/bin/env python3
+
+import urllib.request
+import json
+
+url= "http://httpbin.org/get"
+
+with urllib.request.urlopen(url) as response_json:
+ data_json= json.loads(response_json.read().decode("utf-8"))
+ print(data_json)
diff --git a/Python Tools/Opening and reading URLs(urllib)/urllib_post_request.py b/Python Tools/Opening and reading URLs(urllib)/urllib_post_request.py
new file mode 100644
index 0000000..7c6f367
--- /dev/null
+++ b/Python Tools/Opening and reading URLs(urllib)/urllib_post_request.py
@@ -0,0 +1,11 @@
+import urllib.request
+import urllib.parse
+
+#POST request
+
+data_dictionary = {"id": "0123456789"}
+data = urllib.parse.urlencode(data_dictionary)
+data = data.encode('ascii')
+
+with urllib.request.urlopen("http://httpbin.org/post", data) as response:
+ print(response.read().decode('utf-8'))