One Minute Man

Discussion of challenges you have already solved
chr1s
Posts: 5
Joined: Thu Mar 05, 2009 5:03 pm
Location: Germany, BW

Post by chr1s »

hey. I did it with groovy.. maybe to much - but I want to get more familar with it...

Code: Select all

/**
 * author: 		chr1s <hacker-org@woernswildweb.de>
 * name:		OneMinuteMan.groovy
 * description:	Solution for challenge "One Minute Man" @ http://www.hacker.org
 * date:		20090306
 */

 def url = new URL("http://www.hacker.org/challenge/misc/minuteman.php");
 def bResult = false;

while (!bResult) {
	try {
	
	def httpConnection = url.openConnection();
	def result = httpConnection.inputStream.getText();
	
	if(!result.contains("back later")){
		println("It is currently ${ new Date() }");
		println("We got it! The result is:");
		println(result);
		bResult = true;
	} else {
		println("It is currently ${ new Date() }");
		println("There is no result this time...");
	}
	// Wait 30 sec.
	sleep(30000);
	
	// The connection times out sometimes and it is possible to get 
	// other exceptions, so we catch them all...
	} catch (Exception e) {
		println("It is currently ${ new Date() }");
		println("Error while connecting server!");
		sleep(10000);
	}
}
Greets,
chr1s
PeterS
Posts: 24
Joined: Thu Mar 05, 2009 7:17 pm

Post by PeterS »

Hey, I did it in python, too.
This is my script:

Code: Select all

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import gobject
import urllib
import hashlib

def ask_oracle():
	request = urllib.urlopen("http://www.hacker.org/challenge/misc/minuteman.php")
	response = request.read()
	print request.headers['Date']
	if hashlib.sha224(response).hexdigest() != "eda9e0a89b789cc71670e98bd4d584f3db1028ad6f8d215f89d5a95a":
		print "solution found."
		f = open("minuteman.txt", "w")
		f.write(response)
		gobject.timeout_add(0, loop.quit)
	return True

loop = gobject.MainLoop()
ask_oracle() # initial request
gobject.timeout_add(20 * 1000, ask_oracle) # ask every 20 seconds
loop.run()
Since my script prints the Date header of the HTTP response I can see at what time I got the solution.
It was: Sun, 08 Mar 2009 17:37:49 GMT. (This time must have been roughly correct.)
But I don't understand why the script didn't go off at 03:52 (for all americans here: 03:52 AM), when it was supposed to do so according to the php script I got in the body of that response:

Code: Select all

<?
$x = (int)(time() / 60);
$x %= (60 * 24);
//echo $x;
if ($x == 232) echo "i declare the answer is gugglemuggle";
else echo "back later";
?>
I think the time of this site's php server is not set correctly. But the time of the apache server somehow is?
misterjack
Posts: 4
Joined: Sat Mar 07, 2009 3:36 pm
Location: Germany

Post by misterjack »

First:

Code: Select all

wget http://www.hacker.org/challenge/misc/minuteman.php && mv minuteman.php diff
Started yesterday:

Code: Select all

watch -n 60 "wget http://www.hacker.org/challenge/misc/minuteman.php && diff minuteman.php diff >> answer && rm minuteman.php"
today I did: cat answer and solved the challenge :)
kap
Posts: 3
Joined: Thu Oct 30, 2008 10:09 pm

Post by kap »

i just used java as i had already opened netbeans :D i subclassed a timerTask and executed it every now and then:

Code: Select all

/**
 * @author Kap
 */
class Task extends TimerTask {
	static URL url;
	static InputStream is;
	static String check = "<html><body>\nback later";
	static long counter = 0;

	public Task() {
		try {
			url = new URL( "http://www.hacker.org/challenge/misc/minuteman.php" );
		} catch( MalformedURLException ex ) {
			// does not occur ;)
		}

	}

	@Override
	public void run() {
		try {
			if( counter %50 == 0 )
				System.out.println();
			++counter;
			is = url.openStream();
			String s = new Scanner( is ).useDelimiter( "\\Z" ).next();

			if( s.equals( check ) ) {
				System.out.print(  "." );
			} else {
				System.out.println( s );
				exit();
			}
		} catch( Exception e ) {
			System.print( "_" ); // exceptions occur due to network errors etc
		} finally {
			if( is != null )
				try {
					is.close();
				} catch( IOException e ) { }
		}
	}
}
the main class is quite simple:

Code: Select all

	/**
	 * Creates a new instance of <code>LazyServer</code>.
	 */
	public LazyServer() { }

	public static void main( String[] args ) throws IOException {
		new Timer().schedule( new Task() , 0, 31000 ); // execute twice a minute
	}
greetz, kap
blundfried
Posts: 3
Joined: Thu Mar 19, 2009 12:50 pm

Post by blundfried »

and here another one:
matlab...

Code: Select all

compstring='<html><body> back later';
b=0;
c=clock;
seconds=int8(c(6)/10);
while b==0;
    c=clock;
    seconds2=int8(c(6)/10);
    if seconds2~=seconds    
        file=urlread('http://www.hacker.org/challenge/misc/minuteman.php');
        file2=file;
        file2(13)=' ';
        file2(18)=' ';
        a=strfind(file2,compstring);
        if isempty(a)
            disp(file);
            b=1;
        end;
    end;
    seconds=seconds2;
end;
disp(clock);
stopped this morning at a quite strange time....
hobbist
Posts: 5
Joined: Sun Jun 28, 2009 4:02 pm

Post by hobbist »

rajahten wrote:I used this python script, which i made.
Guess i could've made it with less code, but i'm still learning :D

Code: Select all

import urllib
import time

proxy = {'http': 'proxyurl'}
opener = urllib.FancyURLopener(proxy)
.
.
.
.
Hi, Just completed the challenge myself, using python. I am learning too, and I don't understand the first part of your code. I used something that by comparison is much simpler:

Code: Select all

filehandle = urllib.urlopen(myPage)
If yours is a better way, could you please explain it?

Thanks!
User avatar
livinskull
Posts: 22
Joined: Fri Jun 26, 2009 12:01 pm
Location: /dev/null
Contact:

Post by livinskull »

Firefox-addon Check4Change :D
matter
Posts: 11
Joined: Mon Oct 12, 2009 7:30 am

Post by matter »

I did mine with PHP...first time it ran, I forgot to output the answer... So all I got was "1:56pm Found the ANSWER!" (GMT+10)

Didn't make that mistake again...
whattheh@ck
Posts: 16
Joined: Wed Jul 16, 2008 2:33 am
Location: here

Post by whattheh@ck »

I'm surprised nobody else used GreaseMonkey... it's great for automation and allows you direct accesses to information the way your browser would show it. Here's my code:

function timedRefresh(timeoutPeriod)
{
setTimeout("location.reload(true);",timeoutPeriod);
}
var oracle=document.getElementsByTagName("html")[0].childNodes[1];
var checktext="<body xmlns=\"http://www.w3.org/1999/xhtml\">\nback later</body>";
var s = new XMLSerializer();
var answer = s.serializeToString(oracle);
if(answer == checktext)
{
JavaScript:timedRefresh(20000); // This is set to 20 seconds in milliseconds
}

it simply refreshes the page every 20 seconds, checks the URL's source code (before the URL executes scripts), and stops refreshing when something changes.

!!!! also... i'm surprised nobody mentioned the coding lesson written in the site's source code(it's actually quite long before it executes scripts to reformat the page). to get the source code i just used a variation of the script above along with a JavaScript "alert". this allows one to catch the code because the alert is executed before any other scripts !!!!
hack the planet
OvO
Posts: 11
Joined: Fri Mar 19, 2010 10:18 pm

Post by OvO »

Code: Select all

import time
import urllib


myfile = file("Minuteman Final Password checker.txt", 'a')
data = urllib.urlopen('http://www.hacker.org/challenge/misc/minuteman.php').read()

while 1:
        data = urllib.urlopen('http://www.hacker.org/challenge/misc/minuteman.php').read()
        time.sleep(10)
        if data != """<html><body>
back later""":
            print >> myfile, data
            myfile(close)
did it with python, worked perfect, got only the data i needed and closed itself afterwards =]
but man did it take long to figure out how to write the code.. =/
marios4
Posts: 2
Joined: Tue Mar 16, 2010 11:47 am

Post by marios4 »

greasemonkey ftw:

Code: Select all

// ==UserScript==
// @name           oracle
// @namespace      http://www.hacker.org
// @include        http://www.quackit.com/javascript/javascript_refresh_page.cfm
// ==/UserScript==
if(window.find("back later", true, false, false, true, false, false))
{	
	setTimeout("window.location.reload(true)", 50000);
}
After some hours the answer finally apeared.
Thidrek
Posts: 1
Joined: Sun Nov 09, 2008 1:17 pm

Post by Thidrek »

Well, this is my python script:

Code: Select all

#! /usr/bin/env python

import time
import urllib2

def crawler():
    f = open('oneminute.txt','w')
    foo = urllib2.urlopen('http://www.hacker.org/challenge/misc/minuteman.php')
    content = ''
    for line in foo:
        content += line
    
    while True:
        time.sleep(30)
        foo = urllib2.urlopen('http://www.hacker.org/challenge/misc/minuteman.php')
        content2 = ''
        for i in foo:
            content2 += i
        if content2 != content:
            f.write(content2)
            f.close()
            return content2

print crawler()
Well, it's not that clean since I reassigned "foo". It just didn't work without and I'm not very familiar with Python, yet. So I was just content with having gotten it to work :D
s_ha_dum
Posts: 2
Joined: Tue Jul 07, 2009 2:56 pm

Post by s_ha_dum »

Perl :

Code: Select all

    use LWP::UserAgent;
    $ua = LWP::UserAgent->new;
    $url = 'http://www.hacker.org/challenge/misc/minuteman.php';
    $g = 'back later';
    while ($g eq 'back later') {
        $gone = $ua->get( $url );
        ($g) = ($gone->content =~ /<html><body>\n(.*)/sm);
        sleep(60);
    }
    print($gone->content);
Open a new xterm and let it run. When the page returns something other than 'back later' the script prints the answer and quits.

...but livingskull's solution is hands down my favorite. I'm installing that addon.
Triton456
Posts: 11
Joined: Sun Oct 25, 2009 5:01 pm
Location: Between Germany and England

Post by Triton456 »

Firefox-addon Check4Change :P
Did the same :D

greetz,
Triton456
Play a Windows CD backwards and hear satanic messages. That’s nothing, play it forwards and it installs Windows.

Music = Life

Same Shit - Different Day
Nullsig
Posts: 3
Joined: Wed Sep 29, 2010 11:16 pm

Post by Nullsig »

Code: Select all

#!/bin/bash
while true; do
wget http://www.hacker.org/challenge/misc/minuteman.php
sleep(30)
end

not the exact code i used (syntax is off but i am at a different computer right now and too lazy to grab it) but essentially I just ran it for hours on my second box until i saw a file size different then the 23bytes of "back later"
Post Reply