Quellcode durchsuchen

calc-pwn

master
galanggg vor 6 Jahren
Ursprung
Commit
7a62f9b77f
2 geänderte Dateien mit 53 neuen und 0 gelöschten Zeilen
  1. +50
    -0
      calc-pwn/calc.py
  2. +3
    -0
      calc-pwn/server.sh

+ 50
- 0
calc-pwn/calc.py Datei anzeigen

@ -0,0 +1,50 @@
#!/usr/bin/python
import sys
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 hitung(x,z,y):
return eval(x+z+y)
#menu operasi
print " /$$ /$$ /$$$$$$ /$$ /$$$$$$$ /$$ /$$ /$$ /$$"
print "| $$ /$$/ /$$__ $$| $$ | $$__ $$| $$ /$ | $$| $$$ | $$"
print "| $$ /$$/ | $$ \__/| $$ | $$ \ $$| $$ /$$$| $$| $$$$| $$"
print "| $$$$$/ | $$$$$$ | $$ | $$$$$$$/| $$/$$ $$ $$| $$ $$ $$"
print "| $$ $$ \____ $$| $$ | $$____/ | $$$$_ $$$$| $$ $$$$"
print "| $$\ $$ /$$ \ $$| $$ | $$ | $$$/ \ $$$| $$\ $$$"
print "| $$ \ $$| $$$$$$/| $$$$$$$$ | $$ | $$/ \ $$| $$ \ $$"
print "|__/ \__/ \______/ |________/ |__/ |__/ \__/|__/ \__/"
print "Author : Galanggg"
print "===============================================================================>"
print "1. Penjumlahan (+)"
print "2. Pengurangan (-)"
print "3. Perkalian (*)"
print "4. Pembagian (:)"
choice = raw_input("Masukkan pilihan Anda (1/2/3/4): ")
num1 = raw_input("Masukkan Bilangan Pertama : ")
num2 = raw_input("Masukkan Bilangan Kedua : ")
if choice == '1':
print num1,"+",num2,"=",hitung(num1,"+",num2)
elif choice == '2':
print num1,"-",num2,"=",hitung(num1,"-",num2)
elif choice == '3':
print num1,"*",num2,"=",hitung(num1,"*",num2)
elif choice == '4':
print num1,"/",num2,"=",hitung(num1,"/",num2)

+ 3
- 0
calc-pwn/server.sh Datei anzeigen

@ -0,0 +1,3 @@
#!/bin/bash
socat TCP-LISTEN:5000,reuseaddr,fork EXEC:./calc2.py

Laden…
Abbrechen
Speichern