Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
####### # # E-scripts on http servers, clients, cgis, etc. # # Note 1: use the eev command (defined in eev.el) and the # ee alias (in my .zshrc) to execute parts of this file. # Executing this file as a whole makes no sense. # An introduction to eev can be found here: # # (find-eev-quick-intro) # http://angg.twu.net/eev-intros/find-eev-quick-intro.html # # Note 2: be VERY careful and make sure you understand what # you're doing. # # Note 3: If you use a shell other than zsh things like |& # and the for loops may not work. # # Note 4: I always run as root. # # Note 5: some parts are too old and don't work anymore. Some # never worked. # # Note 6: the definitions for the find-xxxfile commands are on my # .emacs. # # Note 7: if you see a strange command check my .zshrc -- it may # be defined there as a function or an alias. # # Note 8: the sections without dates are always older than the # sections with dates. # # This file is at <http://angg.twu.net/e/http.e> # or at <http://angg.twu.net/e/http.e.html>. # See also <http://angg.twu.net/emacs.html>, # <http://angg.twu.net/.emacs[.html]>, # <http://angg.twu.net/.zshrc[.html]>, # <http://angg.twu.net/escripts.html>, # and <http://angg.twu.net/>. # ####### # «.lighttpd» (to "lighttpd") # «.lighttpd-test0» (to "lighttpd-test0") # «.lighttpd-test1» (to "lighttpd-test1") # «.lighttpd-vhosts» (to "lighttpd-vhosts") # «.lighttpd-ssl» (to "lighttpd-ssl") # «.simple-http-servers» (to "simple-http-servers") # «.python3-http.server» (to "python3-http.server") # «.rfcs-about-http» (to "rfcs-about-http") # «.test.cgi» (to "test.cgi") # «.cgi-test» (to "cgi-test") # «.wiki_apache» (to "wiki_apache") # «.boa_install» (to "boa_install") # «.boa_secondary» (to "boa_secondary") # «.telnet» (to "telnet") # «.expect_http_client» (to "expect_http_client") # «.eeg_http_client» (to "eeg_http_client") # «.dustmote» (to "dustmote") # «.tcl_http» (to "tcl_http") # «.cgipm-2.56» (to "cgipm-2.56") # «.runtmpcgi» (to "runtmpcgi") # «.disguise-user-agent» (to "disguise-user-agent") # «.cgi_specs» (to "cgi_specs") # «.file_upload» (to "file_upload") # «.file_upload_php3» (to "file_upload_php3") # «.pingless» (to "pingless") # «.squid» (to "squid") # «.thttpd» (to "thttpd") # «.thttpd-compile» (to "thttpd-compile") # «.thttpd-cgis-anywhere» (to "thttpd-cgis-anywhere") # «.cgis-at-zumbi-with-htaccess» (to "cgis-at-zumbi-with-htaccess") # «.nginx» (to "nginx") # «.sinatra» (to "sinatra") # «.perldancer» (to "perldancer") # «.http-insecure» (to "http-insecure") # «.HSTS» (to "HSTS") # «.redirection» (to "redirection") # (find-zsh "installeddebs | sort | grep http") # (find-zsh "availabledebs | sort | grep http") https://wiki.debian.org/WebServers https://en.wikipedia.org/wiki/Comparison_of_web_server_software ##### # # lighttpd # 2013feb02 / 2023jan20 # ##### # «lighttpd» (to ".lighttpd") # (find-status "lighttpd") # (find-vldifile "lighttpd.list") # (find-udfile "lighttpd/") # (find-status "lighttpd-doc") # (find-vldifile "lighttpd-doc.list") # (find-udfile "lighttpd-doc/") # https://www.lighttpd.net/ # https://redmine.lighttpd.net/projects/lighttpd/wiki # https://redmine.lighttpd.net/projects/lighttpd/wiki/TutorialConfiguration # https://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_Configuration # https://redmine.lighttpd.net/projects/lighttpd/wiki/FrequentlyAskedQuestions # (find-zsh "installeddebs | sort | grep lighttpd") # (find-zsh "availabledebs | sort | grep lighttpd") # (find-udgrep "grep --color=auto -nRH --null docroot lighttpd/*") # (find-udgrep "grep --color=auto -nRH --null document-root lighttpd/*") # (find-fline "/etc/lighttpd/lighttpd.conf") # (find-asrootfile "/etc/lighttpd/lighttpd.conf") # file:///var/www/html/index.html # (find-initdfile "lighttpd" "PIDFILE=") # (find-asrootfile "/run/") (find-es "apt" "grep-aptavail") aptrm apache2 libapache2-mod-php7.4 ##### # # lighttpd: a very basic test # 2023jan20 # ##### # «lighttpd-test0» (to ".lighttpd-test0") # (find-fline "/etc/init.d/lighttpd") # (find-fline "/etc/lighttpd/lighttpd.conf") # (find-asrootfile "/etc/lighttpd/lighttpd.conf") # (find-asrootfile "/var/log/lighttpd/" "error.log") # (find-es "netcat" "testport") # (find-es "wget" "curl-I") # (find-es "general" "lsof") * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) testport () { echo hi | netcat -q 0 localhost $1 && echo port $1 listening; } /usr/sbin/lighttpd -tt -f /etc/lighttpd/lighttpd.conf cat /run/lighttpd.pid testport 80 sudo /etc/init.d/lighttpd stop cat /run/lighttpd.pid testport 80 sudo /etc/init.d/lighttpd start cat /run/lighttpd.pid testport 80 curl -I http://127.0.0.1/ curl -I http://127.0.0.1/foo.html sudo lsof -i :80 # (find-sh "curl -I http://127.0.0.1/") # http://127.0.0.1/ # http://127.0.0.1/foo.html ##### # # lighttpd-test1 # 2023jan20 # ##### # «lighttpd-test1» (to ".lighttpd-test1") # https://redmine.lighttpd.net/projects/lighttpd/wiki/TutorialConfiguration # https://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_Configuration # (find-status "lighttpd") # (find-vldifile "lighttpd.list") # (find-udfile "lighttpd/") # (find-fline "/etc/lighttpd/lighttpd.conf") # (find-asrootfile "/etc/lighttpd/lighttpd.conf") # (find-asrootfile "/etc/lighttpd/lighttpd.conf" "# Edrx") # (find-fline "/var/www/") # (find-asrootfile "/var/www/") # (find-man "sudo") sudo bash sudo -u edrx ls /home/edrx/public_html/ sudo -u edrx cat /home/edrx/public_html/foo.html sudo -u www-data ls /home/edrx/public_html/ sudo -u www-data cat /home/edrx/public_html/foo.html * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) /usr/sbin/lighttpd -tt -f /etc/lighttpd/lighttpd.conf /usr/sbin/lighttpd -D -f /etc/lighttpd/lighttpd.conf chmod -v 755 ~/public_html/ lynx -dump http://127.0.0.1/foo.html # (find-fline "~/public_html/" "foo.html") http://127.0.0.1/ # (find-linodepfile "foo.html") # (find-linodefile "public_html/foo.html") # (find-fline "~/public_html/foo.html") ##### # # lighttpd-vhosts # 2023jan26 # ##### # «lighttpd-vhosts» (to ".lighttpd-vhosts") # https://tecadmin.net/setup-virtualhosts-in-lighttpd-server/ # https://redmine.lighttpd.net/projects/lighttpd/wiki/Mod_simple_vhost *** # https://www.cyberciti.biz/faq/howto-lighttpd-virtualhost-configuration/ # https://serverfault.com/questions/375402/virtual-hosting-in-lighttpd # (find-asrootfile "/etc/lighttpd/lighttpd.conf" "server.document-root") # https://www.debianhelp.co.uk/virtualhostslighttpd.htm http://localhost/ http://127.0.0.1/ ##### # # lighttpd-ssl # 2023jan26 # ##### # «lighttpd-ssl» (to ".lighttpd-ssl") # (find-udfile "lighttpd/ssl.txt") # Old: # (find-es "git" "git-instaweb") # (find-status "lighttpd") # (find-vldifile "lighttpd.list") # (find-udfile "lighttpd/") # (find-fline "/etc/lighttpd/") # (find-fline "/etc/init.d/lighttpd") # (find-fline "/etc/rc2.d/" "S20lighttpd") Which script adds the S20lighttpd to /etc/rc2.d/ ? ##### # # simple-http-servers # 2019apr16 # ##### # «simple-http-servers» (to ".simple-http-servers") # https://unix.stackexchange.com/questions/32182/simple-command-line-http-server # https://gist.githubusercontent.com/sumpygump/9908417/raw/5fa991fda103d0b7a0c38512394a83ccada9ad6c/nweb23.c nweb23.c # https://gist.github.com/willurd/5720255 Big list of http static server one-liners # https://www.reddit.com/r/webdev/comments/1fs45z/list_of_ad_hoc_http_server_oneliners/ Python 2.x $ python -m SimpleHTTPServer 8000 Python 3.x $ python -m http.server 8000 busybox httpd $ busybox httpd -f -p 8000 Credit: lvm # (find-angg ".zshrc" "makepageindexhtmls") # (find-angg "LUA/lstoindexhtml.lua") * (eepitch-shell2) * (eepitch-kill) * (eepitch-shell2) http://0.0.0.0:8000/ ##### # # python3 http.server # 2019apr17 # ##### # «python3-http.server» (to ".python3-http.server") # (find-sh "apt-file search python | grep http | grep server | tee /tmp/ophs") # (find-esgrep "grep --color -nH -e server.py /tmp/ophs") # (find-status "libpython3.5-stdlib") # (find-vldifile "libpython3.5-stdlib:amd64.list") # (find-vldifile "libpython3.5-stdlib:amd64.list" "http/server.py") # (find-udfile "libpython3.5-stdlib/") # (find-fline "/usr/lib/python3.5/http/server.py") # (find-multiwindow-intro "that restarts both targets") # (find-efunction 'find-wget) * (eepitch '(shell "http-server")) * (eepitch-kill) * (eepitch '(shell "http-server")) cd ~/TH/R/ python3 -m http.server 8002 * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) cd ~/TH/R/ lstoindexhtml_lua_dirs $(find .* * -type d | sort) * (find-3EE '(eepitch-shell) '(eepitch-shell2)) * (eepitch-shell2) cd ~/TH/R/ python3 -m http.server 8000 * (eepitch-shell) # (find-angg ".emacs" "find-wget") cd ~/TH/R/ date | tee ~/TH/R/2019.1-TD/test lstoindexhtml_lua_dirs $(find 2019.1-TD -type d | sort) wget -q -O - http://0.0.0.0:8000/2019.1-TD/test ##### # # RFCs about HTTP # 2004dec18 # ##### # «rfcs-about-http» (to ".rfcs-about-http") # HTTP/1.0: (find-rfcfile "rfc1945.txt") # HTTP/1.1: (find-rfcfile "rfc2068.txt") # (find-rfcfile "rfc2068.txt" "\n19.5 Changes from HTTP/1.0") ##### # # test.cgi # 2007jul20 # ##### # Test if CGIs are working with a simple sh-based CGI. # «test.cgi» (to ".test.cgi") ##### # # Test if CGIs are working (with "showquery") # 1999aug09 # ##### # «cgi-test» (to ".cgi-test") # For an easier test: # (to "runtmpcgi") apti data-dumper #* cd /usr/lib/cgi-bin/ heredoc showquery.cgi -m 0755 <<'---' #!/usr/bin/perl # (find-pl5file "CGI.pm") print "Content-type: text/plain\n\n"; use CGI; my $query = new CGI; use Data::Dumper; sub pdump { print "\n$_[0]:\n", Dumper($_[1]); } pdump "ENV", \%ENV; pdump "query", $query; --- lynx $LH/cgi-bin/showquery.cgi'?foo=bar' cd /usr/lib/cgi-bin/ cp -v showquery.cgi /var/www/ lynx $LH/showquery.cgi'?foo=bar' ##### # # wikits as CGIs - short version # 1999aug09 # ##### # «wiki_apache» (to ".wiki_apache") # (find-es "tcl" "wikit_cgi") cd /var/www/ rm -Rv wikit/ mkdir wikit/ chmod 777 wikit cd /var/www/wikit/ gzip -cd < $S/http/mini.net/cgi-bin/wikit.gz > wikit_cgi chmod 777 wikit_cgi heredoc wikit.cgi -m 0555 <<'---' #!/bin/sh exec /usr/local/bin/tclkit /var/www/wikit/wikit_cgi wikit --- chmod 755 wikit.cgi lynx $LH/wikit/wikit.cgi # (find-fline "/var/log/apache/") # (find-fline "/var/log/apache/error.log") # Comparing conffiles: # cd /o/etc/apache for i in *.conf; do echo "\n\n $i:\n"; diff $i /etc/apache/$i; done # (find-vldifile "" "apache.") # (find-vldifile "apache.list") # (find-fline "/usr/doc/apache/") # A question: if the default for apache is "inetd", shouldn't the port # 80 be trapped by inetd? # Notes on debugging: # # (find-fline "/etc/init.d/apache") # (find-fline "/usr/sbin/apachectl") bash -x /etc/init.d/apache restart bash -x /usr/sbin/apachectl start echo $? /usr/sbin/apache echo $? strace -f -o ~/s /usr/sbin/apache laf /o/etc/apache/ laf /etc/apache/ --> Restarting apache daemon... failed. # (find-fline "/etc/apache/httpd.conf") Uau! #### # # boa (potato) # 2001jun20 # #### # «boa_install» (to ".boa_install") #* apti boa # (find-vldifile "" "boa") # (find-fline "/etc/init.d/boa") # (find-fline "/sbin/start-stop-daemon" "Usage:") # To keep apache as the default web server: cd /etc find init* rc* | egrep 'boa|apache' find rc* | egrep 'S..boa' rm -v $(find rc* | egrep 'S..boa') /etc/init.d/boa stop /etc/init.d/apache start sleep 1 lsof | grep :www #* # To let boa be the web server (temporarily): /etc/init.d/apache stop /etc/init.d/boa start lsof | grep :www #* # (find-es "general" "lsof-2.0.37") ##### # # boa as a secondary web server (slink) # 99oct24 # ##### # «boa_secondary» (to ".boa_secondary") # See the previous chunk for installation on Debian. # (find-vldifile "boa.list") # (find-fline "/usr/doc/boa/") # (find-fline "/usr/doc/boa/docs/") # (find-fline "/usr/doc/boa/examples/") # (find-fline "/etc/boa/boa.conf") egrep '^#?[A-Z]' /etc/boa/boa.conf |& tee ~/o rm -Rv /tmp/boa/ mkdir /tmp/boa/ cat > /tmp/boa/boa.conf <<'---' Port 8080 User nobody Group nogroup ServerAdmin root@localhost ErrorLog /var/log/boa/error_log AccessLog /var/log/boa/access_log #VerboseCGILogs #ServerName www.your.org.here #VirtualHost #DocumentRoot /var/www DocumentRoot /tmp/boa UserDir public_html DirectoryIndex index.html DirectoryMaker /usr/lib/cgi-bin/boa_indexer KeepAliveMax 100 KeepAliveTimeout 10 MimeTypes /etc/mime.types DefaultType text/plain #AddType application/x-httpd-cgi cgi Alias /doc /usr/doc ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ --- kill $(pidof boa) boa -c /tmp/boa lsof | grep boa cp ~/TH/L/*.html /tmp/boa/ lynx http://angg:8080/ lynx http://angg:8080/cgi-bin/ # lynx complains with "Bad partial reference! Stripping lead dots.". Why? # (find-es "lynx" "lynx_patch_turbo") # (find-fline "/var/log/boa/") # (find-fline "~/EXPECT/") # (find-fline "~/EXPECT/httpc1") cd /usr/src/lynx-2.8.1/ agrep 'Bad partial reference! Stripping lead dots' $(find *) agrep 'BAD_PARTIAL_REFERENCE' $(find *) # (find-lynxfile "src/LYCharUtils.c" "BAD_PARTIAL_REFERENCE") # «expect_http_client» (to ".expect_http_client") expect -c ' spawn telnet 127.0.0.1 8080 expect -re "Connected to \[^\n\]+\n\[^\n\]+\n" send "GET /index.html HTTP/1.0\n\n" expect eof ' ##### # # http via telnet # 2014nov01 # ##### # «telnet» (to ".telnet") # http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol # http://upload.wikimedia.org/wikipedia/commons/c/c6/Http_request_telnet_ubuntu.png * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) telnet 127.0.0.1 80 GET /index.html HTTP/1.0 ##### # # eeg http client # 2004dec18 # ##### # «eeg_http_client» (to ".eeg_http_client") #* cat > $EEG <<'%%%' GET /index.html HTTP/1.0 %%% eeg telnet 127.0.0.1 80 #* cat > $EEG <<'%%%' GET /index.html HTTP/1.0 %%% eeg netcat -q 0 localhost 80 #* ###### # # boa - recompiling # 2000jul03 # ###### # (code-c-d "boa" "/usr/src/boa-0.94.8.1/") pdsc $SDEBIAN/dists/potato/main/source/web/boa_0.94.8.1-1.dsc cd /usr/src/boa-0.94.8.1/ cd src/ ./configure |& tee ../oc # make |& tee ../om make CFLAGS="-O" LDFLAGS="-static" |& tee ../om ldd boa ldd boa_indexer laf boa boa_indexer # (find-boafile "om") # (find-node "(gcc)Link Options" "-static") # (find-node "(make)Catalogue of Rules") # (find-es "make") #* rm -Rv /tmp/boa/ mkdir /tmp/boa/ cd /usr/src/boa-0.94.8.1/src/ cp -v boa boa_indexer /tmp/boa/ cd /tmp/boa/ cat > boa.conf <<'---' Port 8080 User root Group root ErrorLog /dev/null AccessLog /dev/null DocumentRoot /tmp DirectoryMaker /tmp/boa/boa_indexer KeepAliveMax 100 KeepAliveTimeout 10 MimeTypes /dev/null # MimeTypes /etc/mime.types DefaultType text/plain # AddType application/x-httpd-cgi cgi # Alias /doc /usr/doc # ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ --- kill $(pidof boa) /tmp/boa/boa -c /tmp/boa #* lsof | grep boa lynx http://127.0.0.1:8080/ # (find-boafile "") # (find-boafile "odrb") # (find-boafile "debian/rules") # (find-boafile "src/") ##### # # dustmote, a minimal http server written in Tcl (~120 lines) # 99nov15 # ##### # «dustmote» (to ".dustmote") # (find-es "tcl" "dustmote") # Update (2007): I tried the Simtel URL below, it no longer works. # The code of dustmote can be fetched from here: # http://wiki.tcl.tk/4333 # The rest of this block is very old. # ftp://ftp.unicamp.br/pub/simtelnet/win95/webbrows/dumo104.zip #* rm -Rv /usr/src/dustmote/ mkdir /usr/src/dustmote/ cd /usr/src/dustmote/ unzip -a $S/ftp/ftp.unicamp.br/pub/simtelnet/win95/webbrows/dumo104.zip cd /usr/src/dustmote/ cp dustmote.tcl dm8080.tcl ed dm8080.tcl <<'---' 141c vwait forEver . 1,3c set root /home/root/TH/L set default index.html set port 8080 ;# port 80 is used by Apache . w --- # (find-fline "/usr/src/dustmote/") # diff -e dustmote.tcl dm8080.tcl # Its indentation is ugly; use Emacs to fix it. # (progn (find-fline "/usr/src/dustmote/dustmote.tcl") (indent-region (point-min) (point-max) nil) (save-buffer)) # (find-fline "/usr/src/dustmote/dm8080.tcl") #* tclsh dm8080.tcl |& tee /tmp/odm lsof | grep tcl lynx http://127.0.0.1:8080/ ##### # # http from Tcl # 99nov14 # ##### # «tcl_http» (to ".tcl_http") # (find-es "page" "angelfire") # (find-fline "~/TCL/httpwiki") # (find-fline "$S/http/www.angelfire.com/cgi-bin/") expect -c ' set afpasswd xxxxxxxx ;# PUT THE PASSWORD HERE! # package require http 1.0 set answer [http_data [http_get \ http://www.angelfire.com/cgi-bin/bedit -query [http_formatQuery \ fullhpd or2/edrx \ password $afpasswd \ login submit]]] puts $answer ' |& tee /tmp/bedit.html # (find-fline "$S/http/www.angelfire.com/cgi-bin/") # (find-fline "$S/http/www.angelfire.com/cgi-bin/bedit.html") # (find-fline "$S/http/www.angelfire.com/cgi-bin/bedit") # (find-fline "/tmp/bedit.html") lynx /tmp/bedit.html lynx $S/http/www.angelfire.com/cgi-bin/bedit.html cp $S/http/www.angelfire.com/cgi-bin/bedit.html /tmp/bedit.html getforms < /tmp/bedit.html diff /tmp/bedit.html $S/http/www.angelfire.com/cgi-bin/bedit.html agrep -i input /tmp/bedit.html agrep -i input $S/http/www.angelfire.com/cgi-bin/bedit.html cat $S/http/www.angelfire.com/cgi-bin/bedit.html | \ expect -c ' while {[gets stdin li]!=-1} { if {[regexp {<input [^>]*>} $li inp]} { puts $inp } } ' | \ tee ~/o # (find-fline "~/.zshrc" "getforms") getforms < $S/http/www.angelfire.com/cgi-bin/bedit ##### # # Sending and receiving files # 99nov16 # ##### # (find-es "tcl" "cgi.tcl") # (find-cgitclfile "") # (find-cgitclfile "example/") # (find-cgitclfile "example/upload.cgi") # (find-cgitclfile "example/uploadbin.cgi") # (find-fline "/usr/lib/tcl8.0/") # (find-fline "/usr/lib/tcl8.0/http1.0/") # (find-fline "/usr/lib/tcl8.0/http2.0/") # (find-fline "/tmp/upload.html") # (find-fline "/usr/src/dustmote/dm8080.tcl") cd /tmp/ wget -O upload.html http://127.0.0.1/cgi-tcl/upload.cgi edrxnetscape http://127.0.0.1/cgi-tcl/ ##### # # Logging everything on a http connection # 99nov16 # ##### # set info [fconfigure $socketChannel -peername] # set peerName [lindex $info 1] # set when [clock format [clock seconds] ] # puts stdout "$peerName $when" # (find-fline "~/EXPECT/eheaders") # stty -icanon min 1 echo expect -c ' proc answer {socketChannel ip port} { puts "$ip $port" spawn -open $socketChannel interact puts "(closed)" } socket -server answer 8080 vwait forEver ' # On other window: expect -c ' spawn telnet 127.0.0.1 8080 interact timeout 10 exit ' # On still another window: kill $(pidof telnet) ##### # # CGI.pm-2.56 # ##### # «cgipm-2.56» (to ".cgipm-2.56") rm -Rv /usr/src/CGI.pm-2.56/ cd /usr/src/ tar -xvzf $SCPAN/authors/id/LDS/CGI.pm-2.56.tar.gz cd /usr/src/CGI.pm-2.56/ # (code-c-d "cgipm" "/usr/src/CGI.pm-2.56/") # (find-cgipmfile "") ##### # # Basic cgis # 2000may18 # ##### # «runtmpcgi» (to ".runtmpcgi") # (find-angg ".zshrc" "runtmpcgi") # Here's a quick way to test simple cgis: we write them to a scratch # cgi file, set the permission bits and call the scratch cgi via http. # This turned out to be very useful, so I created some functions and # aliases on my .zshrc that do most of the job and reduce the noise. # There are links to them below. # Just print the date, the pwd and the uids/gids. #* cat > /usr/lib/cgi-bin/tmp.cgi <<'--%%--' #!/usr/bin/perl print "Content-type: text/plain\n\n"; print "date: ", `date`; print "pwd: ", `pwd`; print "id: ", `id`; --%%-- chmod 755 /usr/lib/cgi-bin/tmp.cgi echo; wget -q -O - http://127.0.0.1/cgi-bin/tmp.cgi #* # Same, but using a shell function. # (find-angg ".zshrc" "runtmpcgi") runtmpcgi <<'---' #!/usr/bin/perl print "Content-type: text/plain\n\n"; print "date: ", `date`; print "pwd: ", `pwd`; print "id: ", `id`; --- #* # Same, but with even less explicit noise. runperltcgi <<'---' print "date: ", `date`; print "pwd: ", `pwd`; print "id: ", `id`; --- #* # Now that the noise is gone we can use cgis that would look too ugly # otherwise. This one inspects the environment and argv, first on a # plain call, then on an "isindex" call. # (find-es "perl" "Data::Dumper") runperltcgi '?foo=bar' <<'---' use Data::Dumper;sub pdump{print"\n $_[0] =\n",Dumper($_[1]);} pdump '%ENV', \%ENV; pdump '$0', $0; pdump '@ARGV', \@ARGV; --- #---- tmpcgi '?foo' #* # «disguise-user-agent» (to ".disguise-user-agent") # (find-es "wget" "user-agent") # (find-angg ".zshrc" "psne") # A way to use wget on places that won't allow "spiders": # lynx http://127.0.0.1/cgi-bin/tmp.cgi lynx -source http://127.0.0.1/cgi-bin/tmp.cgi > /tmp/ol wget -O - -U 'Lynx/2.8.3rel.1 libwww-FM/2.14' \ http://127.0.0.1/cgi-bin/tmp.cgi \ | tee /tmp/ow l /tmp/o{l,w} #* ##### # # More (?) notes on runperltcgi # 2000aug01 # ##### # (find-es "http" "runtmpcgi") # (find-angg ".zshrc" "runtmpcgi") http://127.0.0.1/cgi-bin/tmp.cgi$1 #* runperltcgi '?foo' <<'---' use Data::Dumper; sub pdump{print"\n $_[0] =\n",Dumper($_[1]);} use CGI; my $query = new CGI; pdump '%ENV', \%ENV; pdump '$0', $0; pdump '@ARGV', \@ARGV; pdump "query", $query; --- #* settmpcgi <<'---' pdump '%ENV', \%ENV; pdump '$0', $0; pdump '@ARGV', \@ARGV; pdump "query", $query; --- tmpcgi '?foo=bar' tmpcgi cat /usr/lib/cgi-bin/tmp.cgi /usr/lib/cgi-bin/tmp.cgi foo=bar #* ##### # # CGI specs # 2000may18 # ##### # «cgi_specs» (to ".cgi_specs") # (code-c-d "apadoc" "/usr/doc/apache/manual/") # (find-apadocfile "misc/FAQ.html" "CGI specification") # (code-c-d "cgispec" "$S/http/hoohoo.ncsa.uiuc.edu/cgi/") # (find-cgispecfile "") # (find-cgispecw3 "overview.html") # (find-cgispecw3 "interface.html") # (find-cgispecw3 "env.html") # (find-cgispecw3 "cl.html") # (find-cgispecw3 "in.html") # (find-cgispecw3 "out.html") # (find-apadocfile "") # (find-apadocfile "cgi_path.html") # (find-apadocfile "handler.html") # (find-apadocfile "suexec.html") ##### # # File upload # 2000jul29 # ##### # «file_upload» (to ".file_upload") # Note that I'm using cgi.tcl to check if the uploads are ok; use this # link for how to install it: # (find-es "tcl" "cgi.tcl") # (find-es "perl" "Data::Dumper") # (find-es "emacs" "w3") # (w3-fetch "http://localhost/cgi-tcl/") # (find-fline "/var/www/cgi-tcl/") # (find-fline "/var/www/cgi-tcl/upload.cgi") # (find-fline "/var/www/cgi-tcl/uploadbin.cgi") # (eeman "3pm HTTP::Message") # (eeman "3pm HTTP::Request") # (eeman "3pm HTTP::Request::Common") # (eeman "3pm LWP::UserAgent") # (find-pl5file "HTTP/Message.pm" "previous content is returned.") # (find-pl5file "HTTP/Request.pm" "Instances of this class are usually") # (find-pl5file "HTTP/Request/Common.pm" "Sending my") # (find-pl5file "LWP/UserAgent.pm" "new LWP::UserAgent") #* cat > /tmp/p <<'---' use Data::Dumper; sub pdump { print "\n $_[0] =\n", Dumper($_[1]); } use LWP::UserAgent; use HTTP::Request::Common; $ua = LWP::UserAgent->new; $request = POST 'http://127.0.0.1/cgi-tcl/upload.cgi', Content_Type => 'form-data', Content => [ name => 'n...a...m...e', file1 => ["$ENV{HOME}/.bashrc"], ]; $response = $ua->request($request); $content = $response->content(); # pdump '$post', $post; # pdump '$response', $response; print $content; --- perl /tmp/p \ | unhtml \ | uniq #* cat > /tmp/p <<'---' use Data::Dumper; sub pdump { print "\n $_[0] =\n", Dumper($_[1]); } use LWP::UserAgent; use HTTP::Request::Common; print LWP::UserAgent -> new -> request(POST 'http://127.0.0.1/cgi-tcl/upload.cgi', Content_Type => 'form-data', Content => [ foo => 'bar', file1 => ["$ENV{HOME}/.bashrc"], ]) -> content(); --- perl /tmp/p \ | unhtml \ | uniq #* ##### # # File upload and php3 # 2000aug01 # ##### # «file_upload_php3» (to ".file_upload_php3") # (find-angg ".zshrc" "perl_http_request") #* cat > /var/www/tmp.php3 <<'---' <? phpinfo() ?> --- perl_http_request > /tmp/o.html <<'---' POST 'http://127.0.0.1/tmp.php3', Content_Type => 'form-data', Content => [ foo => 'bar', file1 => ["$ENV{HOME}/.bashrc"], ] --- lynx /tmp/o.html # Search for "PHP Variables". #* ##### # # Testing if I can connect to a site that refuses ping # 2000aug30 # ##### # «pingless» (to ".pingless") #* function trytoconnect () { expect -c " spawn telnet $1 $2 expect {Connected to} {puts ok} timeout {puts argh} eof {puts argh} " } # Ok: trytoconnect angg.twu.net 80 # Argh: trytoconnect sucuri.mat.puc-rio.br 80 trytoconnect nonexistent.comm 80 #* ##### # # squid # 2000dec01 # ##### # «squid» (to ".squid") apti squid squid-cgi squidclient urlredir aptrm squid squid-cgi squidclient urlredir # I once got this error while using my ISP: ERROR The requested URL could not be retrieved While trying to retrieve the URL: http://www.linuxmagic.org/ The following error was encountered: Connection Failed The system returned: (111) Connection refused The remote host or network may be down. Please try the request again. Your cache administrator is [email protected]. Generated Sun, 26 Nov 2000 04:32:46 GMT by leblon.inx.com.br (Squid/2.3.STABLE3) # (find-status "squid") # (find-status "squid-cgi") # (find-status "squidclient") # (find-status "urlredir") # (find-vldifile "squid-cgi.list") # (find-vldifile "squid.list") # (find-vldifile "squidclient.list") # (find-vldifile "urlredir.list") # (find-fline "/usr/doc/squid-cgi/") # (find-fline "/usr/doc/squid/") # (find-fline "/usr/doc/squidclient/") # (find-fline "/usr/doc/urlredir/") # (find-fline "/usr/doc/squid/HTTP-codes.txt.gz") # (find-w3 "/usr/doc/squid/FAQ.html") # (find-w3 "/usr/doc/squid/FAQ-17.html#ss17.2") # (eeman "1 squidclient") lynx http://127.0.0.1/cgi-bin/cachemgr.cgi ##### # # Connecting to a Tcl interpreter # 2001nov10 # ##### # (find-fline "~/bin/mytcl") # (find-fline "/usr/lib/cgi-bin/") # (find-fline "/usr/lib/cgi-bin/tcltest") # (find-angg ".zshrc" "heredoc") # (find-man "3tcl read") # (find-man "3tcl while") # (find-es "tcl-cipsga" "gets") #* mytcl -c ' while {gets li; puts "%$li"} ' #* mytcl -c 'puts [gets stdin li]; puts <$li>' #* echo foo | mytcl -c 'puts [gets stdin li]; puts <$li>' echo -n foo | mytcl -c 'puts [gets stdin li]; puts <$li>' echo -n | mytcl -c 'puts [gets stdin li]; puts <$li>' #* heredoc /usr/lib/cgi-bin/tcltest -m 755 <<'---' #!/bin/sh \ exec tclsh "$0" "$@" source $env(HOME)/TCL/inc.tcl ##### # # thttpd # 2005oct21 # ##### # «thttpd» (to ".thttpd") # (find-status "thttpd") # (find-vldifile "thttpd.list") # (find-udfile "thttpd/") # (find-fline "/etc/thttpd/thttpd.conf") # (find-man "8 thttpd") # (find-man "8 thttpd" "daemon") # (find-man "8 thttpd" "*.cgi") # I prefer to use -c "*" and make every executable file a cgi. # (find-rfcfile "rfc1945.txt" "Content-Type: text/html") # http://www.acme.com/software/thttpd/ # # The eepitched server: # (find-esgrep "grep -nH -e thttpd *.e") # (find-es "ppp" "thttpd") #* kill -9 $(cat ~/usrc/varwww/pid); sleep 1 rm -Rv ~/usrc/varwww/ mkdir -p ~/usrc/varwww/ cd ~/usrc/varwww/ /usr/sbin/thttpd -p 8080 \ -d ~/usrc/varwww/ \ -i ~/usrc/varwww/pid \ -nor -nos -c "*" -l /dev/null \ -T iso-8859-1 cd ~/usrc/varwww/ date > 1 date > 2 cat > plain.cgi <<'%%%' #!/bin/sh echo -e "Content-type: text/plain\n" echo -e "<html>\n<head><title>T</title></head>\n<body>B</body>\n</html>" %%% chmod 755 plain.cgi cat > html.cgi <<'%%%' #!/bin/sh echo -e "Content-type: text/html\n" echo -e "<html>\n<head><title>T</title></head>\n<body>B</body>\n</html>" %%% chmod 755 html.cgi cat > html-foo <<'%%%' #!/bin/sh echo -e "Content-type: text/html\n" echo -e "<html>\n<head><title>T</title></head>\n<body>B</body>\n</html>" %%% chmod 755 html-foo laf /proc/$(cat ~/usrc/varwww/pid)/ #* # (find-fline "~/usrc/varwww/") # Test: # http://127.0.0.1:8080/ # (find-status "thttpd-util") # (find-vldifile "thttpd-util.list") # (find-udfile "thttpd-util/") ##### # # thttpd from the source # 2005oct27 # ##### # «thttpd-compile» (to ".thttpd-compile") # http://www.acme.com/software/thttpd/ # http://www.acme.com/software/thttpd/thttpd-2.25b.tar.gz #* rm -Rfv ~/usrc/thttpd-2.25b/ tar -C ~/usrc/ -xvzf \ $S/http/www.acme.com/software/thttpd/thttpd-2.25b.tar.gz cd ~/usrc/thttpd-2.25b/ ./configure 2>&1 | tee oc make 2>&1 | tee om #* # (code-c-d "thttpd" "~/usrc/thttpd-2.25b/") # (find-thttpdfile "") ##### # # thttpd: allowing cgis anywhere # 2006jun23 # ##### # «thttpd-cgis-anywhere» (to ".thttpd-cgis-anywhere") # (code-c-d "thttpd" "~/usrc/thttpd-2.25b/" :grep) # (find-thttpdfile "") # (find-thttpdgrep "grep -niH -e cgipat $(find *)") # (find-thttpdfile "thttpd.c" "\"cgipat\"") # (find-thttpdgrep "grep -niH -e cgi_pattern $(find *)") # (find-thttpdfile "cgi-src/ssi.c" "match( cgi_pattern, filename )") # (find-thttpdfile "config.h" "Allow any program ending with a .cgi") # (find-thttpdfile "config.h" "** meaning any string at all") # (find-man "8 thttpd" "Don't do explicit symbolic link checking") # (find-fline "$ASROOT/etc/thttpd/thttpd.conf") # (find-sh0 "sudo chown edrx:edrx /etc/thttpd/thttpd.conf") # (find-fline "/etc/thttpd/thttpd.conf") #chroot nosymlink cgipat=**.cgi sudo /etc/init.d/thttpd restart # (find-sh0 "sudo /etc/init.d/thttpd restart") # (find-sh0 "sudo killall thttpd") # (find-sh0 "ps ax | grep thttpd") ##### # # cgis at zumbi (htaccess) # 2008jan03 # ##### # «cgis-at-zumbi-with-htaccess» (to ".cgis-at-zumbi-with-htaccess") # (find-fline "~/LOGS/2008jan03.omnisys") # (find-netbsdman "ksh" " -f " "noglob") # http://httpd.apache.org/docs/1.3/howto/htaccess.html * (eepitch-zumbi) * (eepitch-kill) * (eepitch-zumbi) cat ~andre/public_html/.htaccess cd ~/public_html/ cat > .htaccess <<'%%%' Options +ExecCGI AddHandler cgi-script .cgi %%% cd ~/public_html/tmp/ cat > test.cgi <<'%%%' #!/bin/sh # echo -e "Content-type: text/html\n\n" echo -e "Content-type: text/plain\n\n" set %%% chmod 755 test.cgi # http://zumbi/~edrx/tmp/ # http://zumbi/~edrx/tmp/test.cgi wget -q -O - http://zumbi/~edrx/tmp/test.cgi Last login: Thu Jan 3 12:35:14 2008 from meskita zumbi - netbsd $ $ cat ~andre/public_html/.htaccess Options +ExecCGI AddHandler cgi-script .cgi $ $ cd ~/public_html/ $ cat > .htaccess <<'%%%' > Options +ExecCGI > AddHandler cgi-script .cgi > %%% $ $ cd ~/public_html/tmp/ $ cat > test.cgi <<'%%%' > #!/bin/sh > # echo -e "Content-type: text/html\n\n" > echo -e "Content-type: text/plain\n\n" > set > %%% $ chmod 755 test.cgi $ $ # http://zumbi/~edrx/tmp/ $ # http://zumbi/~edrx/tmp/test.cgi $ $ wget -q -O - http://zumbi/~edrx/tmp/test.cgi DOCUMENT_ROOT=/omnisys/www/htdocs GATEWAY_INTERFACE=CGI/1.1 HTTP_ACCEPT='*/*' HTTP_CONNECTION=Keep-Alive HTTP_HOST=zumbi HTTP_USER_AGENT=Wget/1.10.2 IFS=' ' OPTIND=1 PATH=/sbin:/bin:/usr/sbin:/usr/bin PS1='$ ' PS2='> ' PS4='+ ' QUERY_STRING= REMOTE_ADDR=192.168.51.181 REMOTE_PORT=65525 REQUEST_METHOD=GET REQUEST_URI='/~edrx/tmp/test.cgi' SCRIPT_FILENAME=/home/edrx/public_html/tmp/test.cgi SCRIPT_NAME='/~edrx/tmp/test.cgi' SERVER_ADDR=192.168.51.181 [email protected] SERVER_NAME=zumbi SERVER_PORT=80 SERVER_PROTOCOL=HTTP/1.0 SERVER_SIGNATURE='<ADDRESS>Apache/1.3.37 Server at zumbi Port 80</ADDRESS> ' SERVER_SOFTWARE='Apache/1.3.37 (Unix)' UNIQUE_ID=R3zyscCoM7UAAAPUBYE $ ##### # # nginx # 2009sep29 # ##### # «nginx» (to ".nginx") # (find-status "nginx") # (find-vldifile "nginx.list") # (find-udfile "nginx/") # (find-fline "/var/www/nginx-default/") # (find-fline "/etc/nginx/") # https://github.com/chaoslawful/lua-nginx-module # http://www.londonlua.org/scripting_nginx_with_lua/index.html ##### # # Sinatra and PerlDancer # 2011jan03 # ##### # «sinatra» (to ".sinatra") # «perldancer» (to ".perldancer") # http://www.sinatrarb.com/intro # http://perldancer.org/ ##### # # http-insecure # 2021jan02 # ##### # «http-insecure» (to ".http-insecure") # https://en.wikipedia.org/wiki/HTTP_Strict_Transport_Security # https://www.cloudflare.com/learning/ssl/why-use-https/ # https://www.securitymetrics.com/blog/are-http-websites-insecure # (find-fline "~/LOGS/2021jan02.emacs") # (find-fline "~/LOGS/2021jan02.emacs" "hsts") * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) # curl -v https://www.youtube.com 2>&1 | tee /tmp/o curl -v https://www.youtube.com 2>&1 | grep -i strict-transport-security # (find-fline "/tmp/o") strict-transport-security: max-age=31536000 ##### # # HSTS # 2021jan08 # ##### # «HSTS» (to ".HSTS") # (find-node "(wget)HTTPS (SSL/TLS) Options") # (find-node "(wget)HTTPS (SSL/TLS) Options" "HSTS") # (find-node "(wget)HTTPS (SSL/TLS) Options" "--no-hsts") ##### # # redirection # 2023jan27 # ##### # «redirection» (to ".redirection") # https://en.wikipedia.org/wiki/URL_redirection # https://en.wikipedia.org/wiki/HTTP_301 # https://en.wikipedia.org/wiki/HTTP_302 # https://mail.google.com/mail/u/0/#inbox/FMfcgzGrcFbggmhdVNwGgGgrmBLLPxvg Hi Jessica! Many thanks! =) My copy at Linode is working - if you try, for example, http://angg.twu.net/eev-videos/ http://anggtwu.net/eev-videos/ you will see that they now list the same files... One question: would it be possible for you to set up the kind of redirection that works for wget too? I don't know the right terminology, but here is an example. If we run this rm -Rv /tmp/edrx-test/ mkdir /tmp/edrx-test/ cd /tmp/edrx-test/ wget http://mirrors.ctan.org/macros/luatex/latex/emoji/emoji-doc.pdf the messages are: --2023-01-27 02:57:48-- http://mirrors.ctan.org/macros/luatex/latex/emoji/emoji-doc.pdf Resolving mirrors.ctan.org (mirrors.ctan.org)... 5.35.249.60 Connecting to mirrors.ctan.org (mirrors.ctan.org)|5.35.249.60|:80... connected. HTTP request sent, awaiting response... 302 Found Location: https://linorg.usp.br/CTAN/macros/luatex/latex/emoji/emoji-doc.pdf [following] --2023-01-27 02:57:49-- https://linorg.usp.br/CTAN/macros/luatex/latex/emoji/emoji-doc.pdf Resolving linorg.usp.br (linorg.usp.br)... 2001:12d0:c000:100::200, 200.144.245.207 Connecting to linorg.usp.br (linorg.usp.br)|2001:12d0:c000:100::200|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 1165104 (1.1M) [application/pdf] Saving to: 'emoji-doc.pdf' emoji-doc.pdf 100%[=====================================>] 1.11M 2.50MB/s in 0.4s 2023-01-27 02:57:49 (2.50 MB/s) - 'emoji-doc.pdf' saved [1165104/1165104] If I understood it correctly there we had a redirection like this, http://mirrors.ctan.org/macros/luatex/latex/emoji/emoji-doc.pdf -> https://linorg.usp.br/CTAN/macros/luatex/latex/emoji/emoji-doc.pdf with a status code 302... I took a look at these pages of the Wikipedia, https://en.wikipedia.org/wiki/URL_redirection https://en.wikipedia.org/wiki/HTTP_301 https://en.wikipedia.org/wiki/HTTP_302 and got the impression that in my case it would be better to use a status code 301, that means: "The HTTP response status code 301 Moved Permanently is used for permanent redirecting, meaning that links or records returning this response should be updated"... What do you think? Thanks in advance! =) Eduardo Ochs http://angg.twu.net/#eev http://anggtwu.net/#eev P.S.: I still have some files outside of public_html that I haven't copied/moved/backed up, but everything will be ready on time! Cheers =) # (find-man "1 lwp-request") # (find-status "libwww-perl") # (find-vldifile "libwww-perl.list") # (find-vldifile "libwww-perl.list" "/usr/bin/lwp-request") # (find-udfile "libwww-perl/") https://medium.com/free-code-camp/web-application-security-understanding-the-browser-5305ed2f1dac https://odino.org/wasec-understanding-the-browser/ https://kmcd.dev/posts/http1.0-from-scratch/ # Local Variables: # coding: utf-8-unix # End: