List soal PWN untuk KSL Seleksi
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
2.9 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. #!/usr/bin/python
  2. import sys, subprocess, re
  3. from os import system as MaManX
  4. def make_secure():
  5. unsafe_word = ['__import__', 'eval', 'execfile', 'file', 'input', 'compile', 'reload']
  6. for unsafe in unsafe_word:
  7. del __builtins__.__dict__[unsafe]
  8. class Unbuffered(object):
  9. def __init__(self, stream):
  10. self.stream = stream
  11. def write(self, data):
  12. self.stream.write(data)
  13. self.stream.flush()
  14. def writelines(self, datas):
  15. self.stream.writelines(datas)
  16. self.stream.flush()
  17. def __getattr__(self, attr):
  18. return getattr(self.stream, attr)
  19. sys.stdout = Unbuffered(sys.stdout)
  20. def banner():
  21. return '''
  22. \033[1;32mWELCOME TO MAMANX PINX SERVICE\033[1;m\033[1;31m
  23. _ __ _____ _ _____ _____ _ _ _____ _____ _____ _____ _ _ _____ _____ _____
  24. | | / // ___|| | | ___ \|_ _|| \ | || __ \ / ___|| ___|| ___ \| | | ||_ _|/ __ \| ___|
  25. | |/ / \ `--. | | | |_/ / | | | \| || | \/ \ `--. | |__ | |_/ /| | | | | | | / \/| |__
  26. | \ `--. \| | | __/ | | | . ` || | __ `--. \| __| | / | | | | | | | | | __|
  27. | |\ \/\__/ /| |____ | | _| |_ | |\ || |_\ \ /\__/ /| |___ | |\ \ \ \./ / _| |_ | \__/\| |___
  28. \_| \_/\____/ \_____/ \_| \___/ \_| \_/ \____/ \____/ \____/ \_| \_| \___/ \___/ \_____/\____/
  29. \033[1;m
  30. \033[1;32mversion [beta 1.1 MAMANK]\033[1;m
  31. '''
  32. def displayMenu():
  33. return '''
  34. Choose a ksl ping service:
  35. 1. Ping only one time
  36. 2. Ping multiple times
  37. 3. Exit MaManX
  38. '''
  39. def main():
  40. make_secure()
  41. print banner()
  42. print displayMenu()
  43. userNumber = raw_input("Masukkan pilihan (1-3): ")
  44. if userNumber == "1" :
  45. host = raw_input("\nMasukkan alamat host : ")
  46. p1 = subprocess.Popen(['/usr/local/bin/ping','-c 5', host], stdout=subprocess.PIPE)
  47. output = p1.communicate()[0]
  48. print output
  49. exit()
  50. elif userNumber == "2" :
  51. user = int(raw_input("\nMasukkan jumlah host: "))
  52. while user <= 1:
  53. user = int(raw_input("\nMasukkan host lebih dari 1 MaManX: "))
  54. for o in range(user):
  55. host = raw_input("Masukkan alamat host ke " +str(o+1) +" : ")
  56. hosts= re.sub('[|,;]', '', host)
  57. pings = MaManX('/usr/local/bin/ping -c 5 ' + hosts )
  58. if (pings == 0):
  59. print host.upper(), "IS UP MAMANX"
  60. else :
  61. print host.upper(), "IS LOST MAMANX"
  62. print ""
  63. elif userNumber == "3" :
  64. print "\nTerimakasih telah menggunakan jasa kami MaManX"
  65. exit()
  66. else :
  67. print "\nMaManX salah masukkin acchh :("
  68. exit()
  69. main()