import socket
# Change the following host and see what IP it prints!
# Host changed to GitHub
host = "github.com"
ip = socket.gethostbyname(host)
print(ip)
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect((ip, 80))
print("Successfully connected!")
[x] Check-In
- What is an IP address?
- Internet Protocol (IP)
Unique address that identifies a device on the internet or a local network
- What is a TCP port?
Represents an application or service-specific endpoint identifier
Port: Logistical construct that identifies a specific process or a type of network service
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect((ip, 80))
# Send a GET request to "/"
s.sendall(b"GET / HTTP/1.1\r\n\r\n")
# Recieve & print 2048 bytes of data
data = s.recv(2048)
print(data.decode())
import requests
# Change the URL to whatever you'd like
# Changed the URL into a github URL
response = requests.get("https://github.com/")
print("Status code:", response.status_code)
print("Headers:", response.headers)
print("Response text:", response.text[:100])
# Add a line to print the "Content-Type" header of the response
# Try an image URL!
aws = "3.130.255.192"
response = requests.get("http://" + aws)
print(response.text)
Configuration
server {
// Listen on virtual "port 80"
listen 80;
listen [::]:80;
server_name 3.130.255.192;
location / {
// Inform server about original client
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
// Forward all requests transparently to the server running on our computer
proxy_pass http://localhost:9099;
}
}
Load Balancing
upstream example.com {
server server1.example.com;
server server1.example.com;
}
HTTP Headers
server {
add_header X-Cool-Header "I love APCSP!";
location /pages {
add_header X-Cooler-Header "This is my secret header!";
}
}
[x] Check In
- Research 1 HTTP header and describe, in detail, its purpose.
HTTP Header: Allow
Allow: lists the set of methods supported by a resource
- header must be sent if server responds wit 405
- an empty allow header indicates that the resource allows no request methods
allow: location /information {
add_header X-Header "XHEADER";
} //Will add 'X-Header' with value of 'XHEADER' to any responses sent from '/information' location It maximizes the speed and capacity utilization and ensures that no server is overworked. Overwork = degredation in performance. Enables the control to access resources outside of a domain. Include CORS into header to create custom headers, can use Postman to request and check response headers. Implementing CORS would mean users will be protected from malicious data. Adding CORS would mean adding more protection to the users and protecting the user data. 'Sudo' allows the terminal to have admin access. Using 'wget' is the fastest and easiest way that we use in class. KASM and some other apps require the install.sh to work. Deploying KASM is related to other topics talked about in the lesson because it involves managing and configuring virtual machines, which requires knowledge of networking and system admin. To set up KASM, you need to create a virtual machine, install the necessary software, and configure the networking settings. You may need to set up security measures such as encryption. To add to this guide, you could explain the basics of networking, as well as how to configure security measures like encryption. See the setup post Total: 0.3
/information
location
</div>
</div>
</div>
/products
of the AWS siteaws = "3.130.255.192"
response = requests.get("http://" + aws+ "/products")
print("Secret Header:", response.headers['X-Cooler-Header'])
[x] CORS Hacks
[x] KASM Hacks
NOT DOING ANYMORE
AWS/RDS Hacks