Follow us on Twitter!
Imagination is more valuable than knowledge - Albert Einstein
Thursday, April 17, 2014
Navigation
Home
HellBoundHackers Main:
HellBoundHackers Find:
HellBoundHackers Information:
Learn
Communicate
Submit
Shop
Challenges
HellBoundHackers Exploit:
HellBoundHackers Programming:
HellBoundHackers Think:
HellBoundHackers Track:
HellBoundHackers Patch:
HellBoundHackers Other:
HellBoundHackers Need Help?
Other
Members Online
Total Online: 14
Guests Online: 12
Members Online: 2

Registered Members: 82813
Newest Member: VesuviusSentinel
Latest Articles
View Thread

HellBound Hackers | Challenges | Timed Challenges

Page 1 of 2 1 2 >
Author

RegEx in python questions

elmiguel
Member



Posts: 160
Location: Your Computer
Joined: 12.12.07
Rank:
God
Posted on 27-07-09 15:11
Hello I have been trying to do the timed challenges in JS. I have completed up to 6. I tried doing timed 6 in JS but trying to get the XMLHttpRequest() to get the data off of google is tricky (unless I'm using the wrong function...?) Anyway, I thought it would be practice to try doing it in a different language, so I chose Python.

I can log into the site and get the page data off of timed6/index.php.

Code
linkNum = re.search("[a-z]{1,}(?= result)", hbh)
word = re.search("[a-z]{1,}(?=<\/strong>)", hbh)




side note: I also notice that the word var is not correct but I will fix it later (ex: if word = google then it finds google, but if word = good bye then only bye is found.)

Anyway, when it finds the regex patterns I get:
Code
<_sre.SRE_Match object at 0x00E42368>




How can I print this in the shell so I see the actual word not its location?




The philosophy of one century is the common sense of the next. -Fortune Cookie

I would like to thank a few friends that I have made here that helped me and deserve to be mentioned:
System_Meltdown, Futility, nvrlivenvrdie, Mastergamer, TrueHacker, S1L3NTKn1GhT, Reelix, ynori7, Demons Halo, kryptor

www.hellboundhackers.org/sig/r/24963.png

www.hellboundhackers.org/sig/hbh2.png
<script>alert('XSS');</script>
Author

RE: RegEx in python questions

elmiguel
Member



Posts: 160
Location: Your Computer
Joined: 12.12.07
Rank:
God
Posted on 27-07-09 15:43
Never mind, using findall() function.




The philosophy of one century is the common sense of the next. -Fortune Cookie

I would like to thank a few friends that I have made here that helped me and deserve to be mentioned:
System_Meltdown, Futility, nvrlivenvrdie, Mastergamer, TrueHacker, S1L3NTKn1GhT, Reelix, ynori7, Demons Halo, kryptor

www.hellboundhackers.org/sig/r/24963.png

www.hellboundhackers.org/sig/hbh2.png
<script>alert('XSS');</script>
Author

RE: RegEx in python questions

elmiguel
Member



Posts: 160
Location: Your Computer
Joined: 12.12.07
Rank:
God
Posted on 27-07-09 16:04
fixed the findall() strings to

Code
linkNum = re.findall("\w+(?= result from)", hbh)
word = re.findall("\w+(?=<\/strong> and post)", hbh)




looks neater but stills doesn't grab the spaces if in ex: "denial of service" only gets service.


The philosophy of one century is the common sense of the next. -Fortune Cookie

I would like to thank a few friends that I have made here that helped me and deserve to be mentioned:
System_Meltdown, Futility, nvrlivenvrdie, Mastergamer, TrueHacker, S1L3NTKn1GhT, Reelix, ynori7, Demons Halo, kryptor

www.hellboundhackers.org/sig/r/24963.png

www.hellboundhackers.org/sig/hbh2.png


Edited by elmiguel on 27-07-09 19:42
<script>alert('XSS');</script>
Author

RE: RegEx in python questions

elmiguel
Member



Posts: 160
Location: Your Computer
Joined: 12.12.07
Rank:
God
Posted on 27-07-09 19:19
Ok, if I have a page opened and I request another, how can I store that data?

for example:

Code
Python using urllib2:
reqPage = 'http://www.site.com'
req2 = urllib2.Request(reqPage, None)
pData = #how do I search through this request for my data?






The philosophy of one century is the common sense of the next. -Fortune Cookie

I would like to thank a few friends that I have made here that helped me and deserve to be mentioned:
System_Meltdown, Futility, nvrlivenvrdie, Mastergamer, TrueHacker, S1L3NTKn1GhT, Reelix, ynori7, Demons Halo, kryptor

www.hellboundhackers.org/sig/r/24963.png

www.hellboundhackers.org/sig/hbh2.png
<script>alert('XSS');</script>
Author

RE: RegEx in python questions

Demons Halo
Member



Posts: 261
Location: Sweden
Joined: 26.03.09
Rank:
Apprentice
Posted on 27-07-09 19:42
elmiguel wrote:
Ok, if I have a page opened and I request another, how can I store that data?

for example:

Code
Python using urllib2:
reqPage = 'http://www.site.com'
req2 = urllib2.Request(reqPage, None)
pData = #how do I search through this request for my data?





1- To store the data you need to receive it first as you know, and then store it somewhere (a variable maybe (?))

2- to search through the request:

Code

req = Request('www.blabla.com', None, headers)  #headers is where cookies goes 
response = urlopen(req)      #open the site
site2string = str(response.read())  #reading the responce as a single string
find_data = site2string.find('YOUR DATA MOHAHAHAH')    #search for your data





http://www.java2s. . .sition.htm





Edited by Demons Halo on 27-07-09 19:44
base_dropper@hotmail.com www.demonshalo.com
Author

RE: RegEx in python questions

elmiguel
Member



Posts: 160
Location: Your Computer
Joined: 12.12.07
Rank:
God
Posted on 27-07-09 19:47
cool thanks reading now,



The philosophy of one century is the common sense of the next. -Fortune Cookie

I would like to thank a few friends that I have made here that helped me and deserve to be mentioned:
System_Meltdown, Futility, nvrlivenvrdie, Mastergamer, TrueHacker, S1L3NTKn1GhT, Reelix, ynori7, Demons Halo, kryptor

www.hellboundhackers.org/sig/r/24963.png

www.hellboundhackers.org/sig/hbh2.png
<script>alert('XSS');</script>
Author

RE: RegEx in python questions

elmiguel
Member



Posts: 160
Location: Your Computer
Joined: 12.12.07
Rank:
God
Posted on 27-07-09 20:31
It seems like I am having trouble retrieving data from here:
Code

google = 'http://www.google.co.uk/search?q=' + word[0]





if I just do http://www.google.com and store the data its does it fine, but not when I do it with search?q= and the end of it.


Any suggestions?...


The philosophy of one century is the common sense of the next. -Fortune Cookie

I would like to thank a few friends that I have made here that helped me and deserve to be mentioned:
System_Meltdown, Futility, nvrlivenvrdie, Mastergamer, TrueHacker, S1L3NTKn1GhT, Reelix, ynori7, Demons Halo, kryptor

www.hellboundhackers.org/sig/r/24963.png

www.hellboundhackers.org/sig/hbh2.png
<script>alert('XSS');</script>
Author

RE: RegEx in python questions


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 27-07-09 21:00
Wow, you posted over 85% of the posts in this thread.


Author

RE: RegEx in python questions

elmiguel
Member



Posts: 160
Location: Your Computer
Joined: 12.12.07
Rank:
God
Posted on 27-07-09 21:53
sad isn't......


But I have fixed most of my issues so far I am trying to figure out how to print out an arrays' index though a var

ex:

Code

intLink = 2
print theLinks[intLink]





gives and error in python:

Code
Traceback (most recent call last):
  File "I:/HBH Work Files/timed6_pyA.py", line 32, in <module>
    print theLinks[intLink]
TypeError: list indices must be integers, not str





The philosophy of one century is the common sense of the next. -Fortune Cookie

I would like to thank a few friends that I have made here that helped me and deserve to be mentioned:
System_Meltdown, Futility, nvrlivenvrdie, Mastergamer, TrueHacker, S1L3NTKn1GhT, Reelix, ynori7, Demons Halo, kryptor

www.hellboundhackers.org/sig/r/24963.png

www.hellboundhackers.org/sig/hbh2.png
<script>alert('XSS');</script>
Author

RE: RegEx in python questions

Demons Halo
Member



Posts: 261
Location: Sweden
Joined: 26.03.09
Rank:
Apprentice
Posted on 27-07-09 22:06
arrays in python are called "lists" =P


http://stackoverf. . .or-objects

use that with a variable to get the index value ^^




Edited by Demons Halo on 27-07-09 22:06
base_dropper@hotmail.com www.demonshalo.com
Author

RE: RegEx in python questions

elmiguel
Member



Posts: 160
Location: Your Computer
Joined: 12.12.07
Rank:
God
Posted on 28-07-09 02:44
hmm weird none of them are working. I have tried all the examples, but for some reason it will not take a variable as an integer it reads it as a string. And for some reason my last for loop is not running....


The philosophy of one century is the common sense of the next. -Fortune Cookie

I would like to thank a few friends that I have made here that helped me and deserve to be mentioned:
System_Meltdown, Futility, nvrlivenvrdie, Mastergamer, TrueHacker, S1L3NTKn1GhT, Reelix, ynori7, Demons Halo, kryptor

www.hellboundhackers.org/sig/r/24963.png

www.hellboundhackers.org/sig/hbh2.png
<script>alert('XSS');</script>
Author

RE: RegEx in python questions

Demons Halo
Member



Posts: 261
Location: Sweden
Joined: 26.03.09
Rank:
Apprentice
Posted on 28-07-09 11:00
well it works when I do it :S

post your code and let me have a look =)


base_dropper@hotmail.com www.demonshalo.com
Author

RE: RegEx in python questions

SySTeM
Member

Your avatar

Posts: 1524
Location: England, UK
Joined: 27.07.05
Rank:
HBH Guru
Posted on 28-07-09 16:22
Demons Halo wrote:
well it works when I do it :S

post your code and let me have a look =)


He can't really post his code as it's for beating a mission, if he does then people can just copy it and use it themselves :-/


img138.imageshack.us/img138/6527/sig2ak1.jpg
www.hellboundhackers.org/sig/r/2783.png

http://www.elites0ft.com/
Author

RE: RegEx in python questions

Demons Halo
Member



Posts: 261
Location: Sweden
Joined: 26.03.09
Rank:
Apprentice
Posted on 28-07-09 17:46
system_meltdown wrote:
Demons Halo wrote:
well it works when I do it :S

post your code and let me have a look =)


He can't really post his code as it's for beating a mission, if he does then people can just copy it and use it themselves :-/


well he can either pm me or just post the loop that is not working so someone could help him fix the syntax =P


base_dropper@hotmail.com www.demonshalo.com
Author

RE: RegEx in python questions

elmiguel
Member



Posts: 160
Location: Your Computer
Joined: 12.12.07
Rank:
God
Posted on 28-07-09 18:49
I can post an example of what I am trying to do:

Code

#Python 2.6.1
intNum = 2 #the random number using 2 for purpose

aArray = ['item1','item2','item3'] # etc, etc..

print aArray[intNum]  #cannot work because its reading intNum as a string






Since I do not know the number right a way nor will it work if I hard code it, I need it to grab the random number that is given. The only way that I know of is to store it in a variable. Which is not hard, but, I need to know how to pass the variable in the index as a integer not a string.


The philosophy of one century is the common sense of the next. -Fortune Cookie

I would like to thank a few friends that I have made here that helped me and deserve to be mentioned:
System_Meltdown, Futility, nvrlivenvrdie, Mastergamer, TrueHacker, S1L3NTKn1GhT, Reelix, ynori7, Demons Halo, kryptor

www.hellboundhackers.org/sig/r/24963.png

www.hellboundhackers.org/sig/hbh2.png
<script>alert('XSS');</script>
Author

RE: RegEx in python questions


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 28-07-09 19:10
Isn't it possible to do int(intNum) to get it as an integer?


Author

RE: RegEx in python questions

Demons Halo
Member



Posts: 261
Location: Sweden
Joined: 26.03.09
Rank:
Apprentice
Posted on 28-07-09 19:33
Code

>>> wtf = 2
>>> list= ['bla 1', 'bla 2', 'bla 3']
>>> print list[wtf]
bla 3




and in case the number you're grabbing is a tiny bit of a string, then use:

Code

int(variable) #This will convert the string into integer, make sure you have only numbers as a value of this variable

str(variable)  #To convert a variable value into a string








Edited by Demons Halo on 28-07-09 19:33
base_dropper@hotmail.com www.demonshalo.com
Author

RE: RegEx in python questions

elmiguel
Member



Posts: 160
Location: Your Computer
Joined: 12.12.07
Rank:
God
Posted on 28-07-09 19:44
You Rock!!!!!


The philosophy of one century is the common sense of the next. -Fortune Cookie

I would like to thank a few friends that I have made here that helped me and deserve to be mentioned:
System_Meltdown, Futility, nvrlivenvrdie, Mastergamer, TrueHacker, S1L3NTKn1GhT, Reelix, ynori7, Demons Halo, kryptor

www.hellboundhackers.org/sig/r/24963.png

www.hellboundhackers.org/sig/hbh2.png
<script>alert('XSS');</script>
Author

RE: RegEx in python questions

elmiguel
Member



Posts: 160
Location: Your Computer
Joined: 12.12.07
Rank:
God
Posted on 28-07-09 20:18
Ok, I am at the final stage of this challenge, all I need help with now is how to post back the data to the same url.....

do I have to subit another request? (I do not think that would be it right, wouldn't it just grab a new page?)

do I just open the page again and post back? (not sure if python keeps it open or not)


The philosophy of one century is the common sense of the next. -Fortune Cookie

I would like to thank a few friends that I have made here that helped me and deserve to be mentioned:
System_Meltdown, Futility, nvrlivenvrdie, Mastergamer, TrueHacker, S1L3NTKn1GhT, Reelix, ynori7, Demons Halo, kryptor

www.hellboundhackers.org/sig/r/24963.png

www.hellboundhackers.org/sig/hbh2.png
<script>alert('XSS');</script>
Author

RE: RegEx in python questions


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 28-07-09 23:13
elmiguel wrote:
Ok, I am at the final stage of this challenge, all I need help with now is how to post back the data to the same url.....

do I have to subit another request? (I do not think that would be it right, wouldn't it just grab a new page?)

do I just open the page again and post back? (not sure if python keeps it open or not)

Basic http. Learn it.


Page 1 of 2 1 2 >