├── rickroll.pbz2 ├── Dockerfile ├── convert.py ├── README.md ├── install.sh └── main.py /rickroll.pbz2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0dayCTF/Rickroll-Server/HEAD/rickroll.pbz2 -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3-alpine 2 | WORKDIR /app 3 | COPY main.py main.py 4 | COPY rickroll.pbz2 rickroll.pbz2 5 | CMD python main.py 6 | 7 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | try: 24 | os.setgroups([]) 25 | os.setgid(grp.getgrnam("nogroup").gr_gid) 26 | os.setuid(pwd.getpwnam("nobody").pw_uid) 27 | except OSError: 28 | print("Failed to drop permissions") 29 | sys.exit() 30 | 31 | 32 | def dataRecv(client, addr): 33 | print(f"[+] Connection from {addr[0]}") 34 | for i in roll: 35 | if type(i) == float: 36 | time.sleep(i) 37 | else: 38 | for j in i: 39 | try: 40 | client.send(j.encode()) 41 | except: 42 | return 43 | client.close() 44 | 45 | print("Ready") 46 | while True: 47 | try: 48 | client, addr = listensock.accept() 49 | except KeyboardInterrupt: 50 | listensock.close() 51 | sys.exit() 52 | except Exception: 53 | continue 54 | thread = threading.Thread(target=lambda:dataRecv(client, addr)) 55 | thread.setDaemon(True) 56 | thread.start() 57 | --------------------------------------------------------------------------------