crossbowerbt / awk-webserver Goto Github PK
View Code? Open in Web Editor NEWA simple webserver, written in GNU awk, that supports directory listing and download of file from the directory where it is launched
A simple webserver, written in GNU awk, that supports directory listing and download of file from the directory where it is launched
gawk
already can talk to a network without assistance from external utilities by utilizing special type of files.
From man
:
The following special filenames may be used with the |& coprocess operator for creating TCP/IP network connections:
/inet/tcp/lport/rhost/rport
/inet4/tcp/lport/rhost/rport
/inet6/tcp/lport/rhost/rport
So listening loop can be much simpler, as a prove of concept, below is the simplest web server in plain gawk
#!/bin/sh
gawk -v ListeningPort=12345 'BEGIN {
content="HTTP/1.1 200 OK\r\n"
content=content "Content-Length: 12\r\n"
content=content "Content-Type: text/plain; charset=utf-8\r\n\r\n"
content=content "Hello World!"
socket = "/inet/tcp/" ListeningPort "/0/0";
while (1) {
printf content |& socket;
}
}'
BTW, the same can be done with bash
and that the reason why on production servers bash
, gawk
and so on has 700 permission and root:root
ownership, to make hackers live harder because the first thing they do if they get access to user's accounts, - utilizing network capability of bash/gawk to create reverse shell.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.