Skip to content

Instantly share code, notes, and snippets.

@intrd
Last active March 3, 2017 06:00
Show Gist options
  • Save intrd/7831a7e9b6d425f76f974a13db2aedf1 to your computer and use it in GitHub Desktop.
Save intrd/7831a7e9b6d425f76f974a13db2aedf1 to your computer and use it in GitHub Desktop.
Script to correctly answer prog100-alien_dna1 @ 3dsctf-2k16
## Script to correctly answer prog100-alien_dna1 @ 3dsctf-2k16
# @author intrd - http://dann.com.br/
# @license Creative Commons Attribution-ShareAlike 4.0 International License - http://creativecommons.org/licenses/by-sa/4.0/
# int_netcat.py - https://gist.github.com/intrd/00a39c83f752acf81775bfa9721e745a
import socket, re, sys
sys.path.append("../../LIBS/")
from int_netcat import Netcat
def dna_sub(am1, am2):
amslen=len(am1)
i=0
for character in am1:
if character==am2[i]:
amslen-=1
i+=1
return amslen
nc = Netcat('54.175.35.248', 8001)
data=nc.read_until(':')
print(data)
number=re.search(r'type (.*):', data).group(1)
print(number)
nc.write(number + '\n')
for x in range(0, 99999):
data=nc.read_until('answer is:')
sample1=re.search(r'Sample 01: (.*) -', data).group(1)
print(sample1)
sample2=re.search(r'Sample 02: (.*)\n', data).group(1)
print(sample2)
answer=dna_sub(sample1,sample2)
print(sample1+"-"+sample2+"="+str(answer))
nc.write(str(answer) + '\n')
#print(data)
# am1="TTTG"
# am2="ATTC"
# answer=dna_sub(am1,am2)
# print(am1+"-"+am2+"="+str(answer))
# am1="CGCT"
# am2="CAGC"
# answer=dna_sub(am1,am2)
# print(am1+"-"+am2+"="+str(answer))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment