diff --git a/README.md b/README.md index 330cacd..ddc0177 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,8 @@ Originally made for Junction Stupidhack 2020; Created by [redsPL](https://sakamo ## Variables that we think are cool! +![](https://f.sakamoto.pl/d6584c01-1c48-42b9-935b-d9a89af4e071file_101.jpg) + - $post_data - array, contains data from urlencoded POSTs - $post_multipart - array, contains URIs to uploaded files from multipart/form-data POSTs - $get_data - array, contains data from GETs diff --git a/config/master.sh b/config/master.sh index 5c40d60..19c2987 100644 --- a/config/master.sh +++ b/config/master.sh @@ -9,20 +9,23 @@ cfg[autoindex]=true cfg[auth_required]=false cfg[auth_realm]="Laura is cute <3" -cfg[ssl]=true +cfg[ssl]=false cfg[ssl_port]=8443 cfg[ssl_cert]='' cfg[ssl_key]='' cfg[extension]='shs' -cfg[extra_headers]='server: HTTP.sh/0.9' +cfg[extra_headers]='server: HTTP.sh/0.91 (devel)' cfg[title]='ddd defies development' -cfg[php_enabled]=true -cfg[python_enabled]=true +cfg[php_enabled]=false +cfg[python_enabled]=false # by default, those logs are placed in the main directory - change it to /var/log/_name_ for production cfg[log_http]='log_http' cfg[log_https]='log_https' cfg[log_misc]='log' + +cfg[proxy]=false +cfg[proxy_url]='http://example.com/' \ No newline at end of file diff --git a/webroot/allegro/index.shs b/webroot/allegro/index.shs deleted file mode 100644 index 0fe519a..0000000 --- a/webroot/allegro/index.shs +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -source templates/head.sh - -echo "
- - -
" diff --git a/webroot/allegro/listing.shs b/webroot/allegro/listing.shs deleted file mode 100755 index ce0148b..0000000 --- a/webroot/allegro/listing.shs +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/bash -cat webroot/allegro/listing_top.txt - -query="$(echo "${get_data[q]}" | sed -s "s/ /%20/g;s/+/%20/g")" -query_nice=$(echo ${get_data[q]} | sed -s "s/+/ /g;") -[[ ${get_data[order]} ]] && order=${get_data[order]} || order='p' - -echo "Searching for '$query_nice'" - -IFS=$'\n' -data=$(curl "https://allegro.pl/listing?string=$query&order=$order" | sed -E 's/<\/article>/\n/g' | grep -ohE "allegro.pl/oferta(.*)") - -cost=($(echo "$data" | grep -Eoh "span class=\"[A-Za-z0-9_]{12}\">([0-9]+|[0-9]+ [0-9]+),<\/span>[0-9]+" | sed -E 's/span class=\"[A-Za-z0-9_]{12}\">//g;s///g;s/<\/span>//g' | grep -ohE "[a-z0-9].allegroimg.com/s[0-9]+/[a-z0-9]{6}/[a-z0-9]{28}/(.*)")) -name=($(echo "${data}" | sed -E 's/<\/a>/\n/g' | grep -ohE 'title="">(.*)' | sed -s 's/title="">//g')) -links=($(echo "${data}" | sed -E 's/"(.*)//g')) - -for (( i=0; i<${#img[@]}; i++ )) do - #echo "
${cost[$i]}PLN
${name[$i]}
" - - echo " - - - - - - - - -
- - ${name[$i]} - - - - - - -
- - - - Kup Teraz! ${cost[$i]} zł - - - -
- - z dostawą: - ??? zł - -
- - - - Popularność: ??? - - - Do końca: ??? - - - - " - - -done - -cat webroot/allegro/listing_bottom.txt diff --git a/webroot/allegro/listing_bottom.txt b/webroot/allegro/listing_bottom.txt deleted file mode 100644 index 4178eaa..0000000 --- a/webroot/allegro/listing_bottom.txt +++ /dev/null @@ -1,820 +0,0 @@ - - - - - - - - - - - -
-
- -  1  - - 2 - - 3 - - ... 179 - - - -
-
- Wersja do druku - -
- - - - - -
- - -
-

- Korzystanie z serwisu oznacza akceptację regulaminu -

- - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/webroot/allegro/listing_top.txt b/webroot/allegro/listing_top.txt deleted file mode 100644 index 5b7852d..0000000 --- a/webroot/allegro/listing_top.txt +++ /dev/null @@ -1,1321 +0,0 @@ - - - - - - - - - Allegro.pl - Więcej niż aukcje. Najlepsze oferty na największej platformie handlowej. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - -
- - - - - - - - - -
-
-

Podgląd strony do wydruku

-

Niniejszy komunikat nie zostanie wydrukowany.

-
- -
- - -
-
-
-
-
-

ibm

- znaleziono 8945 przedmiotów. -
-
-   -   -
- - - -
-
-
-
-
- Dodaj do ulubionych kryteriów wyszukiwania
- RSS dla tych wyników wyszukiwania
-
-
-
- - - - - -
- - - - - - -
- - -
-
-

-
    -
-
-
-
- - - - - -
- -
- - - - - - -
- - -
-
- -
- -
- - - - - - - - - - - - - -
- -
- - - - - -
-
- -
-
-
- Porównanie - - Widok:  - - - -
-
- Strona: - - -   z 179 -
-
- -Sortuj według: - - -
- - - - -
- - - - - - - - - - - - - - diff --git a/webroot/boards/index.shs b/webroot/boards/index.shs deleted file mode 100644 index a710133..0000000 --- a/webroot/boards/index.shs +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash -domainprefix='https://megumin.tech/boards' - -meta[title]='bashchan' -meta[css]='style.css' -source templates/head.sh - -echo " -
-
- bashchan
- a place for all your shitposts -
-" -IFS=$'\n' -for i in $(ls -t storage/threads); do - IFS=':' - array=($(cat storage/threads/$i | head -n 1)) - echo "
" - if [[ ${array[1]} != '' ]]; then - echo "${array[1]} | " - fi - echo "${array[0]}
${array[2]}

" -done - - -echo "

Submit a new thread

-
- - -
-
- - - " diff --git a/webroot/boards/post.shs b/webroot/boards/post.shs deleted file mode 100644 index 58d4c42..0000000 --- a/webroot/boards/post.shs +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash - -title=$(cat ${post_multipart[2]} | sed -s 's//g;s/://g' | tr -d '\n\r') -img=${post_multipart[4]} -img_name=$(basename ${post_multipart[4]}) -rel=$(cat ${post_multipart[0]} | sed -E 's/' ]]; then - echo "Post something!" - return 1 -fi - -if session_verify ${cookies[sh_session]}; then - username=$(session_get_username ${cookies[sh_session]}) -else - username='Anon' -fi - -if [[ $rel == *"new"* ]]; then - rel=$(($(ls storage/threads/ | wc -l)+1)) - touch "storage/threads/$rel" -fi - -if [[ -f "storage/threads/$rel" ]]; then - echo "$username:$title:$msg:$img_name" | sed -E "s/\r//g" >> "storage/threads/$rel" -else - echo "No such thread!!" - return 1 -fi - -meta[redirect]="thread.shs?id=$rel" - -source templates/head.sh - -echo "Submitted succesfully.
-Click here if you're not redirected" diff --git a/webroot/boards/style.css b/webroot/boards/style.css deleted file mode 100644 index 8d1b432..0000000 --- a/webroot/boards/style.css +++ /dev/null @@ -1,42 +0,0 @@ -.center { - margin-left: auto; - margin-right: auto; - max-width: 100%; - display: block; - text-align: center; - margin-bottom: 30px; -} - -.file { - width: 225px -} -.msg { - width: 325px; - height: 125px; -} -.title { - width: 318px; -} -.submit { - width: 95px; -} -.pic { - width: 200px; -} - -.thread_title { - color: #f44; -} - -.poster { - color: #4f4; -} - -.post { - margin: 5px; - background-color: #222; -} -.nolinkdecoration, .nolinkdecoration > div { - color: #ccc; - text-decoration: none; -} diff --git a/webroot/boards/thread.shs b/webroot/boards/thread.shs deleted file mode 100644 index 4df422d..0000000 --- a/webroot/boards/thread.shs +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash -domainprefix='https://megumin.tech/boards' - -id=${get_data[id]} -if [[ $id == '' ]]; then - return 1 -elif [[ $id == *".."* ]]; then - return 1 -fi - -meta[css]='style.css' -meta[title]="Thread #$id" -source templates/head.sh - -echo " -
-
- bashchan
- a place for all your shitposts -
-" - -IFS=$'\n' -for i in $(cat storage/threads/$id); do - IFS=':' - array=($i) - echo "
" - if [[ ${array[1]} != '' ]]; then - echo "${array[1]} | " - fi - echo "${array[0]}
" - if [[ -a "$pwd/i/${array[3]}" ]]; then - echo "" - fi - echo "${array[2]}
" -done - - -echo "
- - -
-
- - - -" diff --git a/webroot/img/branding_chinacat.png b/webroot/img/branding_chinacat.png deleted file mode 100644 index 6dd0b4c..0000000 Binary files a/webroot/img/branding_chinacat.png and /dev/null differ diff --git a/webroot/img/branding_pxplus.png b/webroot/img/branding_pxplus.png deleted file mode 100644 index a2201a6..0000000 Binary files a/webroot/img/branding_pxplus.png and /dev/null differ diff --git a/webroot/index.shs b/webroot/index.shs deleted file mode 100644 index 414d27e..0000000 --- a/webroot/index.shs +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/bash - -meta[title]='HTTP.sh' -meta[author]='Dominika, Laura, Patrycja' -meta[description]='HTTP.sh - a quick and dirty webserver, written in Bash' -meta[keywords]='bash,http,web,server,http.sh' -meta[lang]='en' - -source templates/head.sh - -echo " -" -if [[ ! ${cookies[sh_session]} ]]; then - echo "" -else - echo "
Logged in as ${cookies[username]}| Log out
" -fi -echo " -

HTTP.sh - a quick and dirty webserver, written in Bash

- -

-Although we've seen several attempts to create a Bash web framework, all of them fell flat one way or another.
-We've decided to change that. Did we succeed? You be the judge! -

- -

Download

-

-This web server was tested as much as the time allowed, but we can't say for certain that it's bug free.
-If you want to check out our (dirty) code, download the current tarball.

-We also can't guarantee that HTTP.sh is asbestos free, so proceed with caution. -

- -

Dependencies

-
    -
  1. Bash or 100% compatible shell
  2. -
  3. Ncat - nc/nc.traditional WILL NOT work
  4. -
  5. GNU coreutils (dd, base64 and others)
  6. -
  7. pkill
  8. -
  9. mktemp
  10. -
  11. sha1sum, sha256sum
  12. -
  13. curl (only for a few demos)
  14. -
  15. certbot (only if you'd like to get a SSL cert) -
- -

Demos

-
    -
  1. bashchan (an imageboard)
  2. -
  3. bashbin (a pastebin)
  4. -
  5. bashtube (a YouTube frontend)
  6. -
  7. bashurl (a URL shortener)
  8. -
  9. bashupload (a file uploader)
  10. -
  11. bashallgero (a frontend for a Polish auction site)
  12. -
  13. listing (just a file listing, but it looks mighty cool)
  14. -
- -
-Made by reds, selfisekai and ptrcnull. IF YOU LOG IN, THIS SITE WILL STORE COOKIES ON YOUR PERSONAL COMPUTING DEVICE" diff --git a/webroot/login.shs b/webroot/login.shs deleted file mode 100755 index 63e818b..0000000 --- a/webroot/login.shs +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -if [[ ${post_data[login]} != '' && ${post_data[password]} != '' ]]; then - login ${post_data[login]} ${post_data[password]} - status=$? - if [[ $status == 0 ]]; then - echo ${get_data[r]} > /dev/stderr - if [[ ${get_data[r]} == '' ]]; then - meta[redirect]='/' - else - meta[redirect]="$(echo ${get_data[r]} | sed -s 's/Log in... -
- -
- -
- - -(please make sure that you're connecting over SSL)" diff --git a/webroot/logout.shs b/webroot/logout.shs deleted file mode 100755 index 538ef39..0000000 --- a/webroot/logout.shs +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -logout -meta[redirect]='/' -source templates/head.sh - -echo "Logged out successully. Redirecting.." diff --git a/webroot/pastebin/index.shs b/webroot/pastebin/index.shs deleted file mode 100755 index fcd27a2..0000000 --- a/webroot/pastebin/index.shs +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/bash -domainprefix="https://paste.megumin.tech/" - -if [[ ${post_data[paste]} ]]; then - filepath=$(mktemp -p $pwd XXX) - filename=$(basename $filepath) - if [[ ${post_data[public]} == "on" ]]; then - echo $filename >> $pwd/list - fi - if session_verify ${cookies[sh_session]}; then - echo "$filename:$(session_get_username ${cookies[sh_session]})" >> storage/pastes - fi - echo -e $(echo "${post_data[paste]}" | sed -E 's/\+/ /g;s/\%/\\x/g') > $filepath - meta[redirect]="$domainprefix$filename" -fi - -source templates/head.sh - -echo " - -
- - -
- - -" - -if session_verify ${cookies[sh_session]}; then - echo "

Your pastes:

" - pastes=$(grep -E "$(session_get_username ${cookies[sh_session]})\$" storage/pastes) - if [[ $pastes != '' ]]; then - echo "
    " - for i in $pastes; do - IFS=':' - array=($i) - echo "
  1. ${array[0]}
  2. " - done - echo "
" - else - echo "You currently do not have any pastes." - fi -else - echo "If you log in, we'll be able to show you your paste history here :)" -fi - -echo "

Latest public pastes:

    " -public=$(tac $pwd/list | head -n 10) - -IFS=$'\n' -for i in $public; do - echo "
  1. $i
  2. " -done -unset IFS -echo "" - diff --git a/webroot/pastebin/list b/webroot/pastebin/list deleted file mode 100644 index e69de29..0000000 diff --git a/webroot/register.shs b/webroot/register.shs deleted file mode 100755 index 4913367..0000000 --- a/webroot/register.shs +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -if [[ ${post_data[login]} != '' && ${post_data[password]} != '' ]]; then - register ${post_data[login]} ${post_data[password]} - status=$? - if [[ $status == 0 ]]; then - meta[redirect]='/' - fi -fi - -source templates/head.sh - -if [[ $status == 1 && $reason != '' ]]; then - echo $reason -fi - -echo "

    Register

    -
    - -
    - -
    - - -(please make sure that you're connecting over SSL)" diff --git a/webroot/shortener/index.shs b/webroot/shortener/index.shs deleted file mode 100755 index b785821..0000000 --- a/webroot/shortener/index.shs +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash -domainprefix="https://url.megumin.tech/" -not_found=false - -if [[ ${get_data[u]} ]]; then - id=${get_data[u]} - if [[ -f storage/shortener/$id ]]; then - meta[redirect]=$(cat storage/shortener/$id) - else - not_found=true - fi -fi - -meta[title]="url shortener i guess" -source templates/head.sh - -if [[ $not_found == "true" ]]; then - echo "

    ID not found

    " -else - if [[ ${post_data[url]} ]]; then - if [[ ! -d storage/shortener ]]; then - mkdir storage/shortener - fi - id=$(dd if=/dev/urandom bs=256 count=1 | sha1sum | cut -c 1-8) - link=$(printf $(sed 's/%/\\x/g' <<< ${post_data[url]})) - echo -n $link > storage/shortener/$id - echo "

    URL created: link

    " - else - echo '

    Revolutionary URL shortener

    -
    - - - '; - fi -fi diff --git a/webroot/upload/index.shs b/webroot/upload/index.shs deleted file mode 100755 index 1b017f2..0000000 --- a/webroot/upload/index.shs +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -source templates/head.sh -domainprefix="https://f.megumin.tech/" - -if [[ ${post_multipart} != '' ]]; then - for i in ${post_multipart[@]}; do - asdf=$(mktemp -p $(dirname ${r[uri]}) XXX) - relative=$(realpath --relative-to "$(dirname ${r[uri]})" $asdf) - mv "$i" $asdf - rm "$i" - echo "Your uploaded file" - done -else -echo '
    -
    - - ' -fi diff --git a/webroot/boards/i/empty b/webroot/your_awesome_files_here similarity index 100% rename from webroot/boards/i/empty rename to webroot/your_awesome_files_here diff --git a/webroot/yt/fav.shs b/webroot/yt/fav.shs deleted file mode 100644 index f9d0444..0000000 --- a/webroot/yt/fav.shs +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -if session_verify ${cookies[sh_session]} && [[ ${get_data[v]} != '' ]]; then - title=$(youtube-dl -e "https://youtube.com/watch?v=${get_data[v]}") - if [[ $(cat storage/faves | grep -F "$title" | grep "$(echo ${cookies[username]} | sed -E "s/\r//")") == '' ]]; then - echo "$(session_get_username ${cookies[sh_session]}):${get_data[v]}:$title" >> storage/faves - fi -fi - -source templates/head.sh - -echo "<--- back to main

    Your favourites

    " - -IFS=$'\n' -for i in $(tac storage/faves); do - IFS=':' - array=($i) - echo ""; -done diff --git a/webroot/yt/index.shs b/webroot/yt/index.shs deleted file mode 100755 index 2e57b6d..0000000 --- a/webroot/yt/index.shs +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -source templates/head.sh - -echo "
    - - - - -

    All user's favourites

    " - -IFS=$'\n' -for i in $(tac storage/faves); do - IFS=':' - array=($i) - echo "

    ${array[@]:2:999}

    Favourited by ${array[0]}
    "; -done diff --git a/webroot/yt/search.shs b/webroot/yt/search.shs deleted file mode 100755 index 514f324..0000000 --- a/webroot/yt/search.shs +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash -meta[title]="youtube but not really" -source templates/head.sh - -# GOOD LUCK FIXING IT WHEN GOOGLE BREAKS IT LOL - -echo "
    - - - -" - -if [[ ${get_data[q]} ]]; then - query=${get_data[q]} - query_nice=$(echo ${get_data[q]} | sed -s 's/+/ /g') - - echo "

    Searching for '$query_nice'

    " - data='' - while [[ $data == '' ]]; do - data=$(curl -s "https://www.youtube.com/results?search_query=$query&hl=en&hs=en") - done - - - IFS=$'\n' - id=($(echo $data | sed -E 's/<\/a>/\n/g' | grep -ohE 'watch\?v\=[-A-Za-z0-9_]{11}" (.*) rel\="spf-prefetch"' | sed -E 's/watch\?v\=//g;s/" class="yt-uix-tile-link(.*)//g')) - title=($(echo $data | sed -E 's/<\/a>/\n/g' | grep -ohE 'watch\?v\=[-A-Za-z0-9_]{11}" (.*) rel\="spf-prefetch"' | sed -E 's/watch\?v\=[-A-Za-z0-9_]{11}" class\="yt-uix-tile-link(.*)title\="/ /g;s/" rel\="spf-prefetch"//g')) - unset IFS - - for (( i=0; i<${#id[@]}; i++ )); do - echo "
    ${title[$i]}

    " - done -else - echo "search for something will 'ya?" -fi diff --git a/webroot/yt/unfav.shs b/webroot/yt/unfav.shs deleted file mode 100644 index 6ed4337..0000000 --- a/webroot/yt/unfav.shs +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -if session_verify ${cookies[sh_session]} && [[ ${get_data[v]} != '' ]]; then - name=$(session_get_username ${cookies[sh_session]}) - vid=$(echo -n ${get_data[v]} | sed -E 's/\r//g') - sed -i "/^$name:$vid/d" storage/faves -fi -meta[redirect]='fav.shs' - -source templates/head.sh diff --git a/webroot/yt/watch.shs b/webroot/yt/watch.shs deleted file mode 100755 index cc55bd8..0000000 --- a/webroot/yt/watch.shs +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/bash - -# fetching recommended disabled for speed - -#for i in $(curl https://www.youtube.com/watch?v=${get_data[v]} | grep -ohE "watch\?v\=[A-zaz0-9]{11}" | uniq | cut -c 9-19); do -# echo "

    "; -#done - -if [[ ${get_data[v]} ]]; then - video=$(youtube-dl -J "http://youtube.com/watch?v=${get_data[v]}") - if [[ $video == '' ]]; then - video=$(youtube-dl -J "http://youtube.com/watch?v=${get_data[v]}") - if [[ $video == '' ]]; then - return - fi - fi - #echo "http://youtube.com/watch?v=${get_data[v]}" > /dev/stderr - title=$(echo $video | jq -r '.title') - meta[title]=$title - source templates/head.sh - IFS=$'\n' - urls=($(echo $video | jq -r '.formats[] | select(.format_id == "22" or .format_id == "18").url')) - unset IFS - if [[ ${urls[1]} != '' ]]; then - url=${urls[1]} - else - url=${urls[0]} - fi - echo "
    - - - -

    -

    $title

    -
    -
    - Uploaded by $(echo $video | jq -r '.uploader') on $(date -d "$(echo $video | jq -r '.upload_date')" "+%d %B %Y") -
    -
    - $(echo $video | jq -r '.view_count') views
    - $(echo $video | jq -r '.like_count') likes, $(echo $video | jq -r '.dislike_count') dislikes.
    " - if [[ ${cookies[sh_session]} ]]; then - if [[ $(cat storage/faves | grep $(echo -n ${cookies[username]} | sed -E 's/\r//g') | grep ${get_data[v]}) == '' ]]; then - echo "Add to favourites
    " - else - echo "Remove from favourites
    " - fi - else - echo "Log in to add this video to your favourites!
    " - fi - echo "

    -
    -
    - Description:
    $(echo $video | jq -r '.description' | sed -E 's/$/
    /g')
    -
    "; -else - source templates/head.sh - echo "pls add ?v param i'm still WiP" -fi
lista promowanych przedmiotów
- - - - - Nazwa - - - - Cena - - - - z dostawą - - - - Popularność - - - - Do końca -