├── .github └── workflows │ └── dockerBuild.yml ├── Dockerfile ├── README.md ├── convert.py ├── install.sh ├── main.py └── rickroll.pbz2 /.github/workflows/dockerBuild.yml: -------------------------------------------------------------------------------- 1 | name: Publish DockerHub image 2 | 3 | on: 4 | push: 5 | branches: 6 | - 'main' 7 | tags: 8 | - 'v*' 9 | pull_request: 10 | branches: 11 | - 'main' 12 | 13 | jobs: 14 | build-container: 15 | runs-on: ubuntu-latest 16 | steps: 17 | - name: Checkout code 18 | uses: actions/checkout@v2 19 | 20 | - name: Login to DockerHub 21 | uses: docker/login-action@v1 22 | with: 23 | username: ${{ secrets.DOCKER_USERNAME }} 24 | password: ${{ secrets.DOCKER_ACCESS_TOKEN }} 25 | 26 | - name: Extract metadata (tags, labels) for Docker 27 | id: meta 28 | uses: docker/metadata-action@v3 29 | with: 30 | images: muirlandoracle/rickroll-server 31 | tags: | 32 | type=ref,event=branch 33 | type=sha 34 | type=sha,prefix={{branch}}- 35 | type=sha,format=long 36 | type=sha,format=long,prefix={{branch}}- 37 | type=raw,value=latest 38 | 39 | - name: Build and push 40 | uses: docker/build-push-action@v2 41 | with: 42 | context: . 43 | push: true 44 | tags: ${{ steps.meta.outputs.tags }} 45 | labels: ${{ steps.meta.outputs.labels }} 46 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3-alpine 2 | WORKDIR /app 3 | COPY main.py main.py 4 | COPY rickroll.pbz2 rickroll.pbz2 5 | CMD python -u main.py 6 | 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Terminal Rickroll 2 | 3 | Simple threaded Python Rickroll server. Listens on port 23 by default. 4 | 5 | Rickroll video made using [Video-To-Ascii](https://github.com/joelibaceta/video-to-ascii) and the standard rickroll video from YouTube. 6 | 7 | ***Note:*** *This was made very quickly and is currently very barebones -- it may be improved later depending on my (admittedly disturbing) commitment to rickrolling people.* 8 | 9 | ## To-Do: 10 | - [ ] Add Metrics 11 | - [x] Find a better way to serve the rickroll rather than the huge array import... 12 | - [ ] Try to improve video quality 13 | - [x] Add a service file / Install script 14 | -------------------------------------------------------------------------------- /convert.py: -------------------------------------------------------------------------------- 1 | import time, re, pickle, bz2 2 | 3 | 4 | with open("rickroll.ascii") as h: 5 | data = h.readlines() 6 | 7 | output = [] 8 | tmp = [] 9 | for i in data: 10 | if i.startswith("sleep"): 11 | output.append(tmp) 12 | tmp = [] 13 | output.append(float(i.split(" ")[1])) 14 | else: 15 | tmp.append(re.sub("(\'|echo -en )", "", i)) 16 | 17 | 18 | del output[0][0] 19 | with bz2.BZ2File("rickroll.pbz2", "wb") as h: 20 | pickle.dump(output, h) 21 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [[ $EUID -ne 0 ]]; then 4 | echo "[-] Script needs to be run with root privileges" 5 | exit; 6 | fi 7 | 8 | 9 | get_script_dir () { 10 | SOURCE="${BASH_SOURCE[0]}" 11 | # While $SOURCE is a symlink, resolve it 12 | while [ -h "$SOURCE" ]; do 13 | DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" 14 | SOURCE="$( readlink "$SOURCE" )" 15 | # If $SOURCE was a relative symlink (so no "/" as prefix, need to resolve it relative to the symlink base directory 16 | [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" 17 | done 18 | DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" 19 | } 20 | get_script_dir; 21 | 22 | 23 | echo "[+] Creating the service unit file" 24 | cat << EOF > /etc/systemd/system/rickroll.service 25 | [Unit] 26 | Description=Telnet Rickroll Server 27 | After=network.target 28 | 29 | [Service] 30 | Type=simple 31 | User=root 32 | Group=root 33 | WorkingDirectory=$DIR 34 | ExecStart=$DIR/main.py 35 | [Install] 36 | WantedBy=multi-user.target 37 | EOF 38 | 39 | systemctl enable --now rickroll 40 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import time 3 | import pickle 4 | import socket 5 | import threading 6 | import sys 7 | import signal 8 | import bz2 9 | import os 10 | import pwd 11 | import grp 12 | 13 | 14 | with bz2.BZ2File("rickroll.pbz2", "rb") as h: 15 | roll = pickle.load(h) 16 | 17 | 18 | listensock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 19 | listensock.bind(("0.0.0.0", 23)) 20 | listensock.listen() 21 | 22 | #Try to drop privileges having bound to the port 23 | #0day was here 24 | try: 25 | os.setgroups([]) 26 | os.setgid(grp.getgrnam("nogroup").gr_gid) 27 | os.setuid(pwd.getpwnam("nobody").pw_uid) 28 | except OSError: 29 | print("Failed to drop permissions") 30 | sys.exit() 31 | 32 | 33 | def dataRecv(client, addr): 34 | print(f"[+] Connection from {addr[0]}") 35 | for i in roll: 36 | if type(i) == float: 37 | time.sleep(i) 38 | else: 39 | for j in i: 40 | try: 41 | client.send(j.encode()) 42 | except: 43 | return 44 | client.close() 45 | 46 | print("Ready") 47 | while True: 48 | try: 49 | client, addr = listensock.accept() 50 | except KeyboardInterrupt: 51 | listensock.close() 52 | sys.exit() 53 | except Exception: 54 | continue 55 | thread = threading.Thread(target=lambda:dataRecv(client, addr), daemon=True) 56 | thread.start() 57 | -------------------------------------------------------------------------------- /rickroll.pbz2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MuirlandOracle/Rickroll-Server/d9773dafb65a62b8749756b421ae15e16d934435/rickroll.pbz2 --------------------------------------------------------------------------------