From 7a62f9b77f2c1c9c15cb481c04c8ede4ffa151b9 Mon Sep 17 00:00:00 2001 From: galanggg Date: Fri, 19 Oct 2018 21:13:10 +0800 Subject: [PATCH] calc-pwn --- calc-pwn/calc.py | 50 ++++++++++++++++++++++++++++++++++++++++++++++ calc-pwn/server.sh | 3 +++ 2 files changed, 53 insertions(+) create mode 100755 calc-pwn/calc.py create mode 100755 calc-pwn/server.sh diff --git a/calc-pwn/calc.py b/calc-pwn/calc.py new file mode 100755 index 0000000..fc648b5 --- /dev/null +++ b/calc-pwn/calc.py @@ -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) \ No newline at end of file diff --git a/calc-pwn/server.sh b/calc-pwn/server.sh new file mode 100755 index 0000000..bcd2d57 --- /dev/null +++ b/calc-pwn/server.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +socat TCP-LISTEN:5000,reuseaddr,fork EXEC:./calc2.py \ No newline at end of file