Last active
October 8, 2020 14:20
-
-
Save p4p1/b5280296426e6cc520d843300d34d2a7 to your computer and use it in GitHub Desktop.
🐓🐓🐓🐓
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# Made by papi | |
# Created on: Mon 07 Sep 2020 06:50:04 PM CEST | |
# troj.py | |
# Description: | |
import socket, signal | |
import sys, os, time | |
import time | |
from threading import * | |
KING_FILE='/root/king.txt' | |
USER_NAME='p4p1' | |
PID_FILE='/tmp/pid' | |
def empty_king_file(): | |
open(KING_FILE, 'w').close() | |
# Check if the king file is different than the name | |
# on success return the file descriptor, on error returns None | |
def check_file(): | |
fpr = open(KING_FILE, 'r', encoding='utf-8') | |
val = fpr.read().strip() | |
if val != USER_NAME: | |
fpw = open(KING_FILE, 'w', encoding='utf-8') | |
empty_king_file() # Empty the file before being able to add name | |
return fpw | |
fpr.close() | |
return None | |
# function that changes the king file | |
def change_file(): | |
file = check_file() | |
if file != None: | |
file.write(USER_NAME + '\n') # Need a \n to be appended to act like | |
file.close() # an echo | |
if __name__ == "__main__": | |
if len(sys.argv) == 2: | |
os.kill(int(sys.argv[1]), signal.SIGINT) | |
change_file() | |
time.sleep(0.5) | |
os.system("python3 " + sys.argv[0] + " " + str(os.getpid())) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment