Advertisement
xGHOSTSECx

The Art Of Not Existing

Jan 5th, 2024
1,920
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 8.49 KB | None | 0 0
  1. #   "In 'The Art of Not Existing,' players embark on a captivating journey mastering command-line basics, scripting, and building a secure remote HTTPS server. From navigating folders to scripting personalized greetings, unlocking hidden keys, and controlling file permissions, players hone their skills. They navigate mazes, manipulate symbolic links, explore SSH connections, and delve into tunneling techniques. The game's final challenge involves crafting SSL certificates and configuring an HTTPS server for secure communication. With each quest, players gain expertise in the intricacies of the digital realm, culminating in the activation of a secure SSH tunnel and accessing the remote server. 'The Art of Not Existing' is a dynamic adventure blending practical command-line skills with secure server mastery."
  2.  
  3. #           The Art of Not Existing
  4.  
  5. #   Embark on an immersive journey into command-line mastery, scripting sorcery, and the creation of a secure remote HTTPS server. Crafted by Michael Errington of GhostSec.
  6.  
  7. #   Chapter 1: Initiation - The Whispering Shell
  8.  
  9. #   Side Quest 1: Commands of the Apprentice
  10. #   Master the basics of CLI navigation. Traverse folders using `cd`, reveal hidden realms with `ls -a`, and unravel the secrets of ancient scrolls with `cat`.
  11.  
  12. bash
  13. cd folder  # Enter a mysterious folder
  14. ls -a  # Reveal hidden treasures
  15. cat ancient.txt # Unveil the wisdom in the scrolls
  16.  
  17.  
  18. #   Side Quest 2: Echoes of Greeting
  19. #   Begin your scripting journey with a bash script (`first_script.sh`) that echoes a personalized greeting.
  20.  
  21. bash
  22. #!/bin/bash
  23. echo "Welcome, adventurer!"
  24.  
  25.  
  26. #   Side Quest 3: Key Unveiling
  27. #   Encounter a locked chest and reveal its secrets with a script (`retrieve_key.sh`) to unlock it and expose the hidden key.
  28.  
  29. bash
  30. #!/bin/bash
  31. key_location = "hidden_chest/.hidden_key"
  32. unlocked_key = $(cat "$key_location")
  33. echo "Unlocked key: $unlocked_key"
  34.  
  35.  
  36. #   Side Quest 4: Permissions Prowess
  37. #   Delve into the art of file permissions with `chmod`. Use a Python script (`change_permissions.py`) to grant access to a secured key.
  38.  
  39. python
  40. #!/usr/bin/env python3
  41. import os
  42.  
  43. key_location = "hidden_chest/.hidden_key"
  44. os.chmod(key_location, 0o600)
  45. print(f"Permissions of {key_location} changed successfully.")
  46.  
  47.  
  48. #   Side Quest 5: Navigational Challenges
  49. #   Embark on a journey through a maze of folders. Use `cd` and `ls` to navigate and locate the hidden key.
  50.  
  51. bash
  52. cd maze_folder  # Enter the labyrinth of folders
  53. ls -a  # Explore and discover the elusive key
  54. cat secret_folder/key.txt  # Reveal the hidden treasure
  55.  
  56.  
  57. #   Side Quest 6: Symbolic Links Unveiled
  58. #   Navigate the mystic world of symbolic links. Create a symbolic link to access a hidden directory.
  59.  
  60. bash
  61. ln -s secret_folder link_to_secret  # Create a symbolic link
  62. cd link_to_secret  # Enter the hidden realm through the link
  63. ls -a  # Reveal the secrets within
  64.  
  65.  
  66. #   Side Quest 7: Forge Your Path
  67. Exercise your command over creation. Use `mkdir` to forge a new path and `touch` to create a blank map.
  68.  
  69. bash
  70. mkdir new_path  # Forge a new path in the wilderness
  71. touch blank_map.txt  # Create a blank map for your journey
  72.  
  73.  
  74. #   Side Quest 8: Elemental Deletion
  75. #   Master the art of destruction. Wield `rm` to remove obstacles from your path and clear the way forward.
  76.  
  77. bash
  78. rm obstacle.txt  # Remove obstacles blocking your path
  79. rmdir old_path  # Clear the way by removing an unnecessary path
  80.  
  81.  
  82. #   Side Quest 9: Textual Exploration
  83. #   Dive into the world of text manipulation. Use `grep` to find hidden messages and `sed` to transform the ancient scrolls.
  84.  
  85. bash
  86. grep "hidden" ancient.txt  # Find hidden messages
  87. sed 's/secrets/mysteries/g' ancient.txt  # Transform the ancient scrolls
  88.  
  89.  
  90. #   Side Quest 10: Archive Alchemy
  91. #   Embrace the power of archives. Use `tar` to create a compressed archive and `zip` to unlock its contents.
  92.  
  93. bash
  94. tar -czvf secrets.tar.gz secret_folder  # Create a compressed archive
  95. mkdir extracted_contents  # Forge a path to extract the contents
  96. tar -xzvf secrets.tar.gz -C extracted_contents  # Unlock the secrets
  97.  
  98.  
  99. #   Chapter 2: Gateway to the Remote Realm
  100.  
  101. #   Side Quest 11: Whispers of Ports
  102. #   Eavesdrop on port secrets using `netstat`. Discover the whispered tales of open ports.
  103.  
  104. bash
  105. netstat -tuln  # Eavesdrop on the ports' secrets
  106.  
  107.  
  108. #   Side Quest 12: Password Pilgrimage
  109. #   Embark on a password pilgrimage with `sshpass`. Journey into the remote realm with your password shield.
  110.  
  111. bash
  112. sshpass -p 'your_password' ssh user@remote_server_ip
  113.  
  114.  
  115. #   Side Quest 13: Scripted Connection
  116. #   Automate your journey with a bash script (`connect_to_server.sh`). Let it be your guide to the remote server.
  117.  
  118. bash
  119. #!/bin/bash
  120. user = "your_username"
  121. server_ip = "remote_server_ip"
  122. ssh "$user@$server_ip"
  123.  
  124.  
  125. #   Side Quest 14: Scrolls of Access
  126. #   Gain access to the ancient SSH configuration scrolls with `sudo` and modify them using the powerful `nano`.
  127.  
  128. bash
  129. sudo nano /etc/ssh/sshd_config  # Unravel the secrets within the access scrolls
  130.  
  131.  
  132. #   Side Quest 15: Key Mastery
  133. #   Unlock the power of key-based authentication. Create a key pair with `ssh-keygen` and share it using `ssh-copy-id`.
  134.  
  135. bash
  136. ssh-keygen -t rsa  # Generate a new SSH key pair
  137. ssh-copy-id user@remote_server_ip  # Copy your public key to the remote server
  138.  
  139.  
  140. #   Side Quest 16: Access Control Art
  141. #   Craft a bash script (`access_control.sh`) to control access to the remote realm based on IP addresses.
  142.  
  143. bash
  144. #!/bin/bash
  145. allowed_ip = "192.168.1.1"
  146. sshd_config = "/etc/ssh/sshd_config"
  147. echo "AllowUsers $allowed_ip" | sudo tee -a "$sshd_config"
  148. sudo service ssh restart
  149.  
  150.  
  151. #   Chapter 3: The Art of Tunnels
  152.  
  153. #   Side Quest 17: Local Port Sorcery
  154. #   Discover the magic of Local Port Forwarding. Redirect a local port to a remote service.
  155.  
  156. bash
  157. ssh -L 8080:localhost:80 user@remote_server_ip
  158.  
  159.  
  160. #   Side Quest 18: Remote Port Alchemy
  161. Embark on Remote Port Forwarding. Forward a remote port to a local service.
  162.  
  163. bash
  164. ssh -R 8080:localhost:80 user@remote_server_ip
  165.  
  166.  
  167. #   Side Quest 19: Dynamic Tunnel Enchantment
  168. Dive into Dynamic Port Forwarding. Create a dynamic SOCKS proxy to traverse the mystical realms.
  169.  
  170. bash
  171. ssh -D 8080 user@remote_server_ip
  172.  
  173.  
  174. #   Side Quest 20: Dynamic Tunnel Configuration
  175. Develop a Python script (`dynamic_tunnel.py`) to dynamically configure the SSH tunnel based on user input.
  176.  
  177. python
  178. #!/usr/bin/env python3
  179. import subprocess
  180.  
  181. local_port = input("Enter local port: ")
  182. remote_port = input("Enter remote port: ")
  183. subprocess.run(["ssh", "-L", f"{local_port}:localhost:{remote_port}", "user@remote_server"])
  184.  
  185.  
  186. #   Chapter 4: Secure HTTPS Server Mastery
  187.  
  188. #   Side Quest 21: SSL Crafting
  189. #   Commence the quest by crafting a self-signed SSL certificate using `openssl` for secure communication.
  190.  
  191. bash
  192. openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout key.pem -out cert.pem
  193.  
  194.  
  195. #   Side Quest 22: HTTPS Server Configuration
  196. #   Configure the HTTPS server with `nginx`. Design a majestic server block within an `nginx` configuration file.
  197.  
  198. nginx
  199. server {
  200.     listen 127.0.0.1:443 ssl;
  201.     ssl_certificate /path/to/cert.pem;
  202.     ssl_certificate_key /path/to/key.pem;
  203.  
  204.     location / {
  205.         root /path/to/your/website;
  206.         index index.html;
  207.     }
  208. }
  209.  
  210.  
  211. #   Side Quest 23: HTTPS Tunneling Enigma
  212. #   Modify the SSH tunnel to incorporate port forwarding for HTTPS. Ensure secure communication.
  213.  
  214. bash
  215. ssh -L 443:localhost:443 user@remote_server_ip
  216.  
  217.  
  218. #   Final Side Quest: Secure Tunnel Activation Script
  219. #   Craft a bash script (`secure_activate_tunnel.sh`) to guide you in activating the secure SSH tunnel and accessing the remote HTTPS server.
  220.  
  221. bash
  222. #!/bin/bash
  223.  
  224. read -p "Enter local port for SSH tunnel: " local_ssh_port
  225. read -p "Enter remote port for SSH tunnel: " remote_ssh_port
  226. read -p "Enter local port for HTTPS server: " local_https_port
  227.  
  228. # Start the SSH tunnel with port forwarding for HTTPS
  229. ssh -L "$local_ssh_port:localhost:$remote_ssh_port" user@remote_server_ip -N &
  230.  
  231. # Activate the HTTPS server on localhost
  232. sudo nginx -c /etc/nginx/sites-available/https_server
  233.  
  234. echo "Secure SSH tunnel and HTTPS server activated successfully!"
  235.  
  236.  
  237. #   Success - The Art of Not Existing
  238.  
  239. #   Congratulations, Master of the Shell! Your journey has successfully navigated the intricacies of command-line mastery, scripting sorcery, and the secrets of SSH tunneling. The creation and removal of files and directories, along with your adept manipulation of symbolic links, symbolize your profound control over the digital realm.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement