Created
October 24, 2017 14:19
-
-
Save intrd/bff86dea74b379b23a77ac8c1934bed6 to your computer and use it in GitHub Desktop.
casino 2 - prog150 @ hackaflag 2017 - porto alegre
This file contains hidden or 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/python | |
## casino 2 - prog150 @ hackaflag 2017 - porto alegre | |
# @author intrd - http://dann.com.br/ + pwn4food team | |
# int_netcat.py: https://gist.github.com/intrd/00a39c83f752acf81775bfa9721e745a | |
import re, sys, string, math, time, os, random | |
sys.path.append("../../LIBS") | |
from int_netcat import Netcat | |
def get_maior(n, x=False): | |
first = int(n[0]) | |
last = int(n[-1]) | |
data = {} | |
if last>first: | |
data["point"] = last | |
data["discard"] = first | |
else: | |
data["point"] = first | |
data["discard"] = last | |
if x: | |
n=n[1:] | |
n=n[:-1] | |
return n | |
return data | |
# n = [5,3,2,9,4,1] | |
# n = map(int, n) | |
# print n | |
# n = sorted(n) | |
# print n | |
# n = n[len(n)/2:] | |
# print n | |
# exit() | |
# for i in range(0,len(n)/2): | |
# answer = get_maior(n) | |
# print answer | |
# n = get_maior(n,True) | |
# exit() | |
while 1: | |
nc = Netcat('138.197.10.170', 41114) | |
#nc = Netcat('138.197.10.170', 14441) | |
data=nc.read_until("start:") | |
nc.write("start") | |
m=0 | |
while 1: | |
data=nc.read_until("resposta") | |
print(data) | |
n1=re.search(r"\): \[(.*)\]", data).group(1).split("=")[0] | |
n1 = n1.replace(" ", "") | |
n = n1.split(",") | |
if "HACK" in data: | |
exit() | |
#n = [5,3,2,9,4,1] | |
ss=0 | |
for i in range(0,len(n)/2): | |
answer = get_maior(n) | |
print answer | |
n = get_maior(n,True) | |
ss+=answer["point"] | |
# n = map(int, n) | |
# print n | |
# n = sorted(n) | |
# print n | |
# n = n[len(n)/2:] | |
# print n | |
# ss=sum(n) | |
# print ss | |
nc.write(str(ss)+"\n") | |
#print nc.read() | |
#exit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment