Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions TEST/app.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
import flask
from flask import Flask, render_template
import requests
import sqlite3


app = Flask(__name__)

PORT = 8001

@app.route('/', methods=['GET'])
def home():
database = sqlite3.connect('./Captured_requests.db')
cursor = database.cursor()
entries = cursor.execute('select * from all_requests order by Request_Number desc')

return render_template("home.html", entries=entries)
try:
# Open a database connection and fetch entries
with sqlite3.connect('./Captured_requests.db') as database:
cursor = database.cursor()
cursor.execute('SELECT * FROM all_requests ORDER BY Request_Number DESC')
entries = cursor.fetchall() # Fetch all results

# Render the entries in the template
return render_template("home.html", entries=entries)

except sqlite3.Error as e:
# Handle database connection or query errors
print(f"Database error: {e}")
return "An error occurred while fetching data from the database."

if __name__ == "__main__":
app.run(port=PORT)
app.run(port=PORT)
52 changes: 45 additions & 7 deletions TEST/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@
flex: 1;
min-width: 45%;
}

.hero-section {
background: url('https://via.placeholder.com/1200x600') no-repeat center center/cover;
height: 400px;
display: flex;
justify-content: center;
align-items: center;
color: white;
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}
</style>
</head>
<body class="min-h-screen bg-black text-white">
Expand All @@ -57,20 +67,31 @@
<div class="hidden md:block">
<div class="ml-10 flex items-center space-x-4">
<a href="#" class="text-gray-300 hover:text-blue-400 px-3 py-2 rounded-md font-medium">Recent</a>
<a href="#about" class="text-gray-300 hover:text-blue-400 px-3 py-2 rounded-md font-medium">About</a>
<a href="#contact" class="text-gray-300 hover:text-blue-400 px-3 py-2 rounded-md font-medium">Contact</a>
</div>
</div>
</div>
</div>
</nav>

<!-- Hero Section -->
<section class="hero-section gradient-bg text-center">
<div>
<h1 class="text-4xl font-bold mb-4">Welcome to CRISP</h1>
<p class="text-xl mb-8">Modern Request Logger for your development needs</p>
<a href="#recent-requests" class="px-6 py-3 bg-blue-600 hover:bg-blue-700 text-white font-semibold rounded-lg shadow-lg">Get Started</a>
</div>
</section>

<!-- Main Content -->
<main class="pt-24 pb-16 px-4 sm:px-6 lg:px-8 max-w-7xl mx-auto">
<h1 class="text-4xl font-bold text-gray-100 mb-8">Recent Requests</h1>
<h2 id="recent-requests" class="text-4xl font-bold text-gray-100 mb-8">Recent Requests</h2>

<!-- Request Cards -->
<section>
{% for entry in entries %}
<article class="entry flex-container">
<article class="entry flex-container card-hover">
<div class="box flex-item">
<h2 class="entry__title">Request</h2>
<p class="entry__content"><pre style="overflow-x: auto; white-space: pre-wrap; word-wrap: break-word; font-size: 15px;">{{entry[1]}}</pre></p>
Expand All @@ -84,18 +105,35 @@ <h2 class="entry__title">Response</h2>
</section>
</main>

<!-- About Section -->
<section id="about" class="bg-gray-800 py-16 text-center text-white">
<h2 class="text-3xl font-bold mb-4">About CRISP</h2>
<p class="text-xl mb-4">CRISP is a modern and easy-to-use request logger that helps developers track and debug API calls and responses in real-time.</p>
<p class="text-lg">It features an intuitive interface and powerful filtering to view requests and responses with ease.</p>
</section>

<!-- Footer -->
<footer class="bg-blue-800 text-white">
<div class="max-w-7xl mx-auto py-12 px-4 sm:px-6 lg:px-8">
<footer id="contact" class="bg-blue-800 text-white py-12">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="grid grid-cols-1 md:grid-cols-2 gap-8">
<div>
<h3 class="text-lg font-semibold mb-4">About</h3>
<h3 class="text-lg font-semibold mb-4">Contact Us</h3>
<p>If you have any questions, feel free to reach out to us:</p>
<ul class="mt-4 space-y-2">
<li>Email: <a href="mailto:info@crisp.com" class="text-blue-400">info@crisp.com</a></li>
<li>Phone: +1 (123) 456-7890</li>
</ul>
</div>
<div>
<h3 class="text-lg font-semibold mb-4">Social</h3>
<div class="space-y-2">
<p>Project Wing 2025 Cyber Domain</p>
<a href="#" class="text-blue-400">Twitter</a>
<a href="#" class="text-blue-400">Facebook</a>
<a href="#" class="text-blue-400">GitHub</a>
</div>
</div>
</div>
</div>
</footer>
</body>
</html>
</html>
103 changes: 64 additions & 39 deletions proxy_server/modified_response_proxy_server.py
Original file line number Diff line number Diff line change
@@ -1,54 +1,72 @@
import socket
import threading
import logging

# Setup logging for better traceability
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')

def modify_request(request):
"""Modify the request before forwarding it."""
logging.debug("Modifying request...")
# Example modification: Change User-Agent header
modified_request = request.replace("User-Agent: Mozilla", "User-Agent: BurpClone")
return modified_request

def modify_response(response):
"""Modify the response before sending it back to the client."""
logging.debug("Modifying response...")
# Example: Modify the response content
if "origin" in response:
response = response.replace("103.106.200.60", "127.0.0.1") # Modify IP for testing purposes
return response

def handle_client_request(client_socket):
print("Received request:")
request = b''
client_socket.setblocking(False)

while True:
try:
data = client_socket.recv(1024)
if not data:
"""Handles the client's request, modifying and forwarding it to the destination."""
try:
# Receiving the request
request = b''
client_socket.setblocking(False)

while True:
try:
data = client_socket.recv(1024)
if not data:
break
request += data
logging.debug(f"Received data: {data.decode('utf-8', errors='ignore')}")
except BlockingIOError:
break
request += data
print(data.decode('utf-8'), end='')
except BlockingIOError:
break

# Modify the request before forwarding
modified_request = modify_request(request.decode('utf-8'))
host, port = extract_host_port_from_request(modified_request)

# Forward the modified request to the destination
destination_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
destination_socket.connect((host, port))
destination_socket.sendall(modified_request.encode('utf-8'))
print("Request forwarded to the destination")

while True:
response = destination_socket.recv(1024)
if not response:
break
# Modify the response before sending it to the client
modified_response = modify_response(response.decode('utf-8'))
client_socket.sendall(modified_response.encode('utf-8'))

destination_socket.close()
client_socket.close()

# Modify the request
modified_request = modify_request(request.decode('utf-8'))
host, port = extract_host_port_from_request(modified_request)

# Forwarding the modified request to the destination server
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as destination_socket:
destination_socket.connect((host, port))
destination_socket.sendall(modified_request.encode('utf-8'))
logging.debug("Request forwarded to the destination")

# Receive the response from the destination server
response = b""
while True:
data = destination_socket.recv(1024)
if not data:
break
response += data
# Modify the response before sending it back to the client
modified_response = modify_response(response.decode('utf-8'))
client_socket.sendall(modified_response.encode('utf-8'))

logging.debug("Response sent back to the client")

except Exception as e:
logging.error(f"Error handling request: {e}")
finally:
client_socket.close()

def extract_host_port_from_request(request):
"""Extract the host and port from the HTTP request."""
host_string_start = request.find('Host: ') + len('Host: ')
host_string_end = request.find('\r\n', host_string_start)
host_string = request[host_string_start:host_string_end]
Expand All @@ -61,16 +79,23 @@ def extract_host_port_from_request(request):
return host, port

def start_proxy_server(port=8080):
"""Start the proxy server."""
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
server.bind(('127.0.0.1', port))
server.listen(5)
print(f"Proxy server running on port {port}")
logging.info(f"Proxy server running on port {port}")

while True:
client_socket, client_address = server.accept()
print(f"Accepted connection from {client_address}")
client_handler = threading.Thread(target=handle_client_request, args=(client_socket,))
client_handler.start()
try:
while True:
client_socket, client_address = server.accept()
logging.info(f"Accepted connection from {client_address}")
client_handler = threading.Thread(target=handle_client_request, args=(client_socket,))
client_handler.start()
except KeyboardInterrupt:
logging.info("Shutting down the proxy server...")
finally:
server.close()

if __name__ == "__main__":
start_proxy_server()