From f04e55410018a98bbafb8c909d5857b0049351a6 Mon Sep 17 00:00:00 2001 From: "Paul S. Ferrell" Date: Thu, 8 Oct 2009 15:05:07 -0600 Subject: [PATCH 1/5] Added summary files for each puzzle category. --- puzzles/bletchley/summary.txt | 0 puzzles/compaq/summary.txt | 0 puzzles/hackme/summary.txt | 0 puzzles/posters/summary.txt | 0 puzzles/sequence/summary.txt | 0 puzzles/survey/summary.txt | 0 puzzles/webapp/summary.txt | 0 7 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 puzzles/bletchley/summary.txt create mode 100644 puzzles/compaq/summary.txt create mode 100644 puzzles/hackme/summary.txt create mode 100644 puzzles/posters/summary.txt create mode 100644 puzzles/sequence/summary.txt create mode 100644 puzzles/survey/summary.txt create mode 100644 puzzles/webapp/summary.txt diff --git a/puzzles/bletchley/summary.txt b/puzzles/bletchley/summary.txt new file mode 100644 index 0000000..e69de29 diff --git a/puzzles/compaq/summary.txt b/puzzles/compaq/summary.txt new file mode 100644 index 0000000..e69de29 diff --git a/puzzles/hackme/summary.txt b/puzzles/hackme/summary.txt new file mode 100644 index 0000000..e69de29 diff --git a/puzzles/posters/summary.txt b/puzzles/posters/summary.txt new file mode 100644 index 0000000..e69de29 diff --git a/puzzles/sequence/summary.txt b/puzzles/sequence/summary.txt new file mode 100644 index 0000000..e69de29 diff --git a/puzzles/survey/summary.txt b/puzzles/survey/summary.txt new file mode 100644 index 0000000..e69de29 diff --git a/puzzles/webapp/summary.txt b/puzzles/webapp/summary.txt new file mode 100644 index 0000000..e69de29 From 98f50c363318b337696a27524c791995cfe39556 Mon Sep 17 00:00:00 2001 From: "Paul S. Ferrell" Date: Thu, 8 Oct 2009 15:12:27 -0600 Subject: [PATCH 2/5] Setup mkpuzzles to ignore summary.txt puzzle files. --- mkpuzzles.py | 3 ++ puzzles/webapp/40/,binary.png | Bin 16 -> 626 bytes puzzles/webapp/40/,ctf.css | 55 +++++++++++++++++++++++++++++++++- 3 files changed, 57 insertions(+), 1 deletion(-) mode change 120000 => 100644 puzzles/webapp/40/,binary.png mode change 120000 => 100644 puzzles/webapp/40/,ctf.css diff --git a/mkpuzzles.py b/mkpuzzles.py index 3d3e0da..243bf29 100755 --- a/mkpuzzles.py +++ b/mkpuzzles.py @@ -21,6 +21,9 @@ for cat in os.listdir(opts.puzzles): dirname = os.path.join(opts.puzzles, cat) for points in os.listdir(dirname): pointsdir = os.path.join(dirname, points) + if not os.path.isdir(pointsdir): + continue + outdir = os.path.join(opts.htmldir, cat, points) try: os.makedirs(outdir) diff --git a/puzzles/webapp/40/,binary.png b/puzzles/webapp/40/,binary.png deleted file mode 120000 index 736df8b..0000000 --- a/puzzles/webapp/40/,binary.png +++ /dev/null @@ -1 +0,0 @@ -../1/,binary.png \ No newline at end of file diff --git a/puzzles/webapp/40/,binary.png b/puzzles/webapp/40/,binary.png new file mode 100644 index 0000000000000000000000000000000000000000..81cecbf90b7be1b43d200329faf3acccd3584ad4 GIT binary patch literal 626 zcmeAS@N?(olHy`uVBq!ia0vp^+(695!3HFgJ}hYlQjEnx?oJHr&dIz4a@dl*-CY>| zgW!U_%O?XxI14-?i-FpNL70(Y)*K0-AbW|YuPggaPH|CQq11ydeLx|}64!_l=ltB< z)VvY~=c3falGGH1^30M91$R&1fbd2>aiCRaJzX3_BqSLRG1~rP1Zw&Z#6$rmqEtZ@ zv4Ch!PEH0zMMbdC{rmSBzJLD?X6x(ggXxPGFM?^X$&!+i49}lG2V)Q$24IR{e6V6J zE-r?TA3uUIh>Z(?6*Dn0G5q`Yk3mUEi2=mM1;8>Og&;-u?%e}x!lfAO!EfKbG4S#6 vfz^Q6xBxhuLGDygPynmJ78)Q4kY`DXlmaf(Fx>}!b|B53u6{1-oD!M<6bWKV literal 0 HcmV?d00001 diff --git a/puzzles/webapp/40/,ctf.css b/puzzles/webapp/40/,ctf.css deleted file mode 120000 index 32cad37..0000000 --- a/puzzles/webapp/40/,ctf.css +++ /dev/null @@ -1 +0,0 @@ -../1/,ctf.css \ No newline at end of file diff --git a/puzzles/webapp/40/,ctf.css b/puzzles/webapp/40/,ctf.css new file mode 100644 index 0000000..4b1b9a0 --- /dev/null +++ b/puzzles/webapp/40/,ctf.css @@ -0,0 +1,54 @@ +html,body { + height: 100%; + min-height: 100%; + background-color: #000000; + background-image: url(",binary.png"); + background-repeat: repeat-x repeat-y; + margin: 0; + padding: 0; +} + +#wrapper { + min-height: 100%; + height: 100%; + width: 800px; + margin: 0 auto; + border-left: 2px solid #009900; + border-right: 2px solid #009900; + font: .9em monospace; + color: #009900; + padding: 0; + background: #000; +} + +#content { + padding: 2em 1.5em 2em 1.5em; +} + +#footer { + padding: 0; + margin: 0; + height: 2em; + line-height: 2em; + width: 800px; + text-align: center; +} + +input { + background-color: #222; + color: #fff; + border: 1px solid #009900; + padding: 1px 2px 1px 2px; +} + +h1,h2,h3,h4 { + padding-bottom: 5px; +} + +.vertsep { + width: 100%; + height: 1px; + padding: 0; + margin: 2em auto 2em auto; + border-bottom: 1px dotted #222; +} From 1ca3e319e141e293ac042687394159285f8e3cba Mon Sep 17 00:00:00 2001 From: Curt Hash Date: Thu, 8 Oct 2009 15:52:01 -0600 Subject: [PATCH 3/5] fixed symlinks --- puzzles/webapp/20/,binary.png | 2 +- puzzles/webapp/20/,ctf.css | 2 +- puzzles/webapp/30/,binary.png | 2 +- puzzles/webapp/30/,ctf.css | 2 +- puzzles/webapp/40/,binary.png | Bin 626 -> 17 bytes puzzles/webapp/40/,ctf.css | 55 +--------------------------------- 6 files changed, 5 insertions(+), 58 deletions(-) mode change 100644 => 120000 puzzles/webapp/40/,binary.png mode change 100644 => 120000 puzzles/webapp/40/,ctf.css diff --git a/puzzles/webapp/20/,binary.png b/puzzles/webapp/20/,binary.png index 736df8b..36053bd 120000 --- a/puzzles/webapp/20/,binary.png +++ b/puzzles/webapp/20/,binary.png @@ -1 +1 @@ -../1/,binary.png \ No newline at end of file +../10/,binary.png \ No newline at end of file diff --git a/puzzles/webapp/20/,ctf.css b/puzzles/webapp/20/,ctf.css index 32cad37..19b2533 120000 --- a/puzzles/webapp/20/,ctf.css +++ b/puzzles/webapp/20/,ctf.css @@ -1 +1 @@ -../1/,ctf.css \ No newline at end of file +../10/,ctf.css \ No newline at end of file diff --git a/puzzles/webapp/30/,binary.png b/puzzles/webapp/30/,binary.png index 736df8b..36053bd 120000 --- a/puzzles/webapp/30/,binary.png +++ b/puzzles/webapp/30/,binary.png @@ -1 +1 @@ -../1/,binary.png \ No newline at end of file +../10/,binary.png \ No newline at end of file diff --git a/puzzles/webapp/30/,ctf.css b/puzzles/webapp/30/,ctf.css index 32cad37..19b2533 120000 --- a/puzzles/webapp/30/,ctf.css +++ b/puzzles/webapp/30/,ctf.css @@ -1 +1 @@ -../1/,ctf.css \ No newline at end of file +../10/,ctf.css \ No newline at end of file diff --git a/puzzles/webapp/40/,binary.png b/puzzles/webapp/40/,binary.png deleted file mode 100644 index 81cecbf90b7be1b43d200329faf3acccd3584ad4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 626 zcmeAS@N?(olHy`uVBq!ia0vp^+(695!3HFgJ}hYlQjEnx?oJHr&dIz4a@dl*-CY>| zgW!U_%O?XxI14-?i-FpNL70(Y)*K0-AbW|YuPggaPH|CQq11ydeLx|}64!_l=ltB< z)VvY~=c3falGGH1^30M91$R&1fbd2>aiCRaJzX3_BqSLRG1~rP1Zw&Z#6$rmqEtZ@ zv4Ch!PEH0zMMbdC{rmSBzJLD?X6x(ggXxPGFM?^X$&!+i49}lG2V)Q$24IR{e6V6J zE-r?TA3uUIh>Z(?6*Dn0G5q`Yk3mUEi2=mM1;8>Og&;-u?%e}x!lfAO!EfKbG4S#6 vfz^Q6xBxhuLGDygPynmJ78)Q4kY`DXlmaf(Fx>}!b|B53u6{1-oD!M<6bWKV diff --git a/puzzles/webapp/40/,binary.png b/puzzles/webapp/40/,binary.png new file mode 120000 index 0000000..36053bd --- /dev/null +++ b/puzzles/webapp/40/,binary.png @@ -0,0 +1 @@ +../10/,binary.png \ No newline at end of file diff --git a/puzzles/webapp/40/,ctf.css b/puzzles/webapp/40/,ctf.css deleted file mode 100644 index 4b1b9a0..0000000 --- a/puzzles/webapp/40/,ctf.css +++ /dev/null @@ -1,54 +0,0 @@ -html,body { - height: 100%; - min-height: 100%; - background-color: #000000; - background-image: url(",binary.png"); - background-repeat: repeat-x repeat-y; - margin: 0; - padding: 0; -} - -#wrapper { - min-height: 100%; - height: 100%; - width: 800px; - margin: 0 auto; - border-left: 2px solid #009900; - border-right: 2px solid #009900; - font: .9em monospace; - color: #009900; - padding: 0; - background: #000; -} - -#content { - padding: 2em 1.5em 2em 1.5em; -} - -#footer { - padding: 0; - margin: 0; - height: 2em; - line-height: 2em; - width: 800px; - text-align: center; -} - -input { - background-color: #222; - color: #fff; - border: 1px solid #009900; - padding: 1px 2px 1px 2px; -} - -h1,h2,h3,h4 { - padding-bottom: 5px; -} - -.vertsep { - width: 100%; - height: 1px; - padding: 0; - margin: 2em auto 2em auto; - border-bottom: 1px dotted #222; -} diff --git a/puzzles/webapp/40/,ctf.css b/puzzles/webapp/40/,ctf.css new file mode 120000 index 0000000..19b2533 --- /dev/null +++ b/puzzles/webapp/40/,ctf.css @@ -0,0 +1 @@ +../10/,ctf.css \ No newline at end of file From 6fb8d935ec43cb22f7a6190b9bff4427d6270bae Mon Sep 17 00:00:00 2001 From: Curt Hash Date: Thu, 8 Oct 2009 15:54:42 -0600 Subject: [PATCH 4/5] summary of puzzles 1-4 --- puzzles/webapp/summary.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/puzzles/webapp/summary.txt b/puzzles/webapp/summary.txt index e69de29..767d14c 100644 --- a/puzzles/webapp/summary.txt +++ b/puzzles/webapp/summary.txt @@ -0,0 +1,8 @@ +10: the key is in the generated source. +20: enter a non-integer into form field and submit. the key is in the resulting + traceback. +30: change the value in the GET request to a non-integer. the key is in the + resulting traceback. +40: change the value in the POST request to a non-integer. the key is in the + resulting traceback. + From fbf09276c05d6ff01695d8bd30700a500cb37189 Mon Sep 17 00:00:00 2001 From: Curt Hash Date: Thu, 8 Oct 2009 16:40:14 -0600 Subject: [PATCH 5/5] changed it so that the response from the polls is not turned into a string until it returns to the poller loop. This allows poll functions to manipulate the raw responses from the socket reads. Also added an ACK to tftdp poller so that the tftpd daemon stops whining about the socket closing without an ACK. --- pollster/pollster.py | 45 +++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/pollster/pollster.py b/pollster/pollster.py index bde9fea..e2e8567 100755 --- a/pollster/pollster.py +++ b/pollster/pollster.py @@ -70,20 +70,17 @@ def socket_poll(ip, port, msg, prot, max_recv=1): sock.send(msg) # get a response - resp = '' + resp = [] try: - # first read - data = sock.recv(1024) - resp += data.decode('utf-8') - max_recv -= 1 - - # remaining reads as necessary until timeout or socket closes - while(len(data) > 0 and max_recv > 0): + # read from the socket until responses or read, + # a timeout occurs, the socket closes, or some other exception + # is raised + for i in range(max_recv): data = sock.recv(1024) - resp += data.decode('utf-8') - max_recv -= 1 - sock.close() - + if len(data) == 0: + break + resp.append(data) + except socket.timeout as e: print('pollster: timed out waiting for a response from %s:%d (%s)' % (ip, port, e)) traceback.print_exc() @@ -91,10 +88,12 @@ def socket_poll(ip, port, msg, prot, max_recv=1): print('pollster: receive from %s:%d failed (%s)' % (ip, port, e)) traceback.print_exc() + sock.close() + if len(resp) == 0: return None - return resp + return b''.join(resp) # PUT POLLS FUNCTIONS HERE # Each function should take an IP address and return a team name or None @@ -105,14 +104,14 @@ def poll_fingerd(ip): resp = socket_poll(ip, 79, b'flag\n', socket.SOCK_STREAM) if resp is None: return None - return resp.strip('\r\n') + return resp.strip(b'\r\n') def poll_noted(ip): ''' Poll the noted service. Returns None or a team name. ''' resp = socket_poll(ip, 4000, b'rflag\n', socket.SOCK_STREAM) if resp is None: return None - return resp.strip('\r\n') + return resp.strip(b'\r\n') def poll_catcgi(ip): ''' Poll the cat.cgi web service. Returns None or a team name. ''' @@ -121,11 +120,11 @@ def poll_catcgi(ip): if resp is None: return None - content = resp.split('\r\n\r\n') + content = resp.split(b'\r\n\r\n') if len(content) < 3: return None - content = content[1].split('\r\n') + content = content[1].split(b'\r\n') try: content_len = int(content[0]) @@ -134,7 +133,7 @@ def poll_catcgi(ip): if content_len <= 0: return None - return content[1].strip('\r\n') + return content[1].strip(b'\r\n') def poll_tftpd(ip): ''' Poll the tftp service. Returns None or a team name. ''' @@ -145,8 +144,12 @@ def poll_tftpd(ip): if len(resp) <= 5: return None - resp = resp.split('\n')[0] - return resp[4:].strip('\r\n') + resp = resp.split(b'\n')[0] + + # ack + resp = socket_poll(ip, 69, b'\x00\x04' + resp[2:4], socket.SOCK_DGRAM, 0) + + return resp[4:].strip(b'\r\n') # PUT POLL FUNCTIONS IN HERE OR THEY WONT BE POLLED POLLS = { @@ -217,7 +220,7 @@ while True: # perform polls for service,func in POLLS.items(): - team = func(ip) + team = str(func(ip)) if team is None: team = 'dirtbags'