Tags: reverse programing
Rating:
```
from pwn import *
import re
def sort_(k1,k2,arr):
arr = map(int, arr)
arr.sort()
arr_k1 = arr[:int(k1)]
arr_k1 = map(str,arr_k1)
arr.sort(reverse=True)
arr_k2 = arr[:int(k2)]
arr_k2 = map(str,arr_k2)
return ", ".join(arr_k1) + ";" + ", ".join(arr_k2)
def main():
conn = remote('challs.xmas.htsp.ro',6051)
for i in range(0,50):
get_res = conn.recvuntil(']')
arr = re.search(r'\[(.*?)\]',get_res).group(1).split(",")
arr = [x.strip(' ') for x in arr]
conn.recvline(1024)
k1 = conn.recvline(1024).decode('utf-8')[5:]
k2 = conn.recvline(1024).decode('utf-8')[5:]
print ("[+] Round {}".format(i))
result = sort_(k1,k2,arr)
conn.sendline(result)
print conn.recvline(1024)
print conn.recv(4096)
if __name__ == '__main__':
main()
```