Page 2 of 3

Posted: Sat Mar 07, 2009 4:27 am
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

Posted: Sun Mar 08, 2009 7:51 pm
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?

Posted: Tue Mar 10, 2009 9:22 am
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 :)

Posted: Fri Mar 27, 2009 9:46 am
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

Posted: Tue Mar 31, 2009 7:10 am
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....

Posted: Sun Jul 12, 2009 12:45 pm
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!

Posted: Sun Jul 12, 2009 2:32 pm
by livinskull
Firefox-addon Check4Change :D

Posted: Mon Nov 23, 2009 4:01 am
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...

Posted: Fri Apr 16, 2010 9:21 pm
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 !!!!

Posted: Tue Apr 20, 2010 9:53 pm
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.. =/

Posted: Mon May 03, 2010 9:39 am
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.

Posted: Mon Sep 13, 2010 10:18 am
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

Posted: Sun Sep 26, 2010 4:28 am
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.

Posted: Thu Oct 07, 2010 5:06 pm
by Triton456
Firefox-addon Check4Change :P
Did the same :D

greetz,
Triton456

Posted: Fri Oct 08, 2010 6:57 pm
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"