List soal PWN untuk KSL Seleksi
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 

77 rader
2.9 KiB

#!/usr/bin/python
import sys, subprocess, re
from os import system as MaManX
def make_secure():
unsafe_word = ['__import__', 'eval', 'execfile', 'file', 'input', 'compile', 'reload']
for unsafe in unsafe_word:
del __builtins__.__dict__[unsafe]
class Unbuffered(object):
def __init__(self, stream):
self.stream = stream
def write(self, data):
self.stream.write(data)
self.stream.flush()
def writelines(self, datas):
self.stream.writelines(datas)
self.stream.flush()
def __getattr__(self, attr):
return getattr(self.stream, attr)
sys.stdout = Unbuffered(sys.stdout)
def banner():
return '''
\033[1;32mWELCOME TO MAMANX PINX SERVICE\033[1;m\033[1;31m
_ __ _____ _ _____ _____ _ _ _____ _____ _____ _____ _ _ _____ _____ _____
| | / // ___|| | | ___ \|_ _|| \ | || __ \ / ___|| ___|| ___ \| | | ||_ _|/ __ \| ___|
| |/ / \ `--. | | | |_/ / | | | \| || | \/ \ `--. | |__ | |_/ /| | | | | | | / \/| |__
| \ `--. \| | | __/ | | | . ` || | __ `--. \| __| | / | | | | | | | | | __|
| |\ \/\__/ /| |____ | | _| |_ | |\ || |_\ \ /\__/ /| |___ | |\ \ \ \./ / _| |_ | \__/\| |___
\_| \_/\____/ \_____/ \_| \___/ \_| \_/ \____/ \____/ \____/ \_| \_| \___/ \___/ \_____/\____/
\033[1;m
\033[1;32mversion [beta 1.1 MAMANK]\033[1;m
'''
def displayMenu():
return '''
Choose a ksl ping service:
1. Ping only one time
2. Ping multiple times
3. Exit MaManX
'''
def main():
make_secure()
print banner()
print displayMenu()
userNumber = raw_input("Masukkan pilihan (1-3): ")
if userNumber == "1" :
host = raw_input("\nMasukkan alamat host : ")
p1 = subprocess.Popen(['/usr/local/bin/ping','-c 5', host], stdout=subprocess.PIPE)
output = p1.communicate()[0]
print output
exit()
elif userNumber == "2" :
user = int(raw_input("\nMasukkan jumlah host: "))
while user <= 1:
user = int(raw_input("\nMasukkan host lebih dari 1 MaManX: "))
for o in range(user):
host = raw_input("Masukkan alamat host ke " +str(o+1) +" : ")
hosts= re.sub('[|,;]', '', host)
pings = MaManX('/usr/local/bin/ping -c 5 ' + hosts )
if (pings == 0):
print host.upper(), "IS UP MAMANX"
else :
print host.upper(), "IS LOST MAMANX"
print ""
elif userNumber == "3" :
print "\nTerimakasih telah menggunakan jasa kami MaManX"
exit()
else :
print "\nMaManX salah masukkin acchh :("
exit()
main()