Follow us on Twitter!
Hacking isn't just Computers & Exploits. It's a Philosophy. - Mr_Cheese
Saturday, April 19, 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: 24
Guests Online: 23
Members Online: 1

Registered Members: 82832
Newest Member: SerMSYS
Latest Articles
View Thread

HellBound Hackers | Computer General | Programming

Page 2 of 2 < 1 2
Author

RE: Some Python Feedback plz


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 14-04-09 23:59
If you have several large numbers, try generating them on the spot, rather than storing them. This takes huge amounts of memory.

for your second question, you can use the extra bit of the range function, so:

range(min,max,step)

If you want every number from 3 to 20000 adding 2 each time, use:

for i in range(3,20000,2)

Hope this helps


Author

RE: Some Python Feedback plz

Demons Halo
Member



Posts: 261
Location: Sweden
Joined: 26.03.09
Rank:
Apprentice
Posted on 15-04-09 13:49
awesome!

Thnx a lot for the tips. That step thing is pretty cool making everything run twice as fast Grin
base_dropper@hotmail.com www.demonshalo.com
Author

RE: Some Python Feedback plz

Demons Halo
Member



Posts: 261
Location: Sweden
Joined: 26.03.09
Rank:
Apprentice
Posted on 16-04-09 18:32
hmm Now that I've got most of my mathematical programs to work a lot faster (thnx to the tips from gothicbob, jjbutler88 and ynori7), I decided to learn a bit about file I/O.
Problem 8 @ Project Euler seems to be a good place to start!

http://projecteuler.net/index.php?section=problems&id=8

Code

fil=open('P8.txt', 'r')
lines=str(fil.read())

for x in lines:
    if x.find('731')==True:
        print 'lal :D'
        break
    else:
        print 'lol :/'
        break   





This is just a test code for the .find method which I can't seem to get right :/ My syntax is somehow wrong...

if line.find('731')==True

This one should be modified somehow. The ==True part should be replaced with some other syntax if I'm not mistaken.

any ideas?

thnx :)

//D.H.




Edited by Demons Halo on 16-04-09 18:33
base_dropper@hotmail.com www.demonshalo.com
Author

RE: Some Python Feedback plz

ynori7
Member



Posts: 1486
Location: #valhalla
Joined: 08.10.07
Rank:
God
Posted on 16-04-09 20:56
Demons Halo wrote:
if line.find('731')==True

The find method returns an index value, not a boolean. If the search string is not found, it returns "-1".
Code
if line.find('731')>=0:







halls-of-valhalla.org/images/affiliateLogo.png voodoorage.halls-of-valhalla.org/images/smallLogo.png
i537.photobucket.com/albums/ff338/ynori77/archenemysig1.jpg
ynori7 http://halls-of-valhalla.org
Author

RE: Some Python Feedback plz

Demons Halo
Member



Posts: 261
Location: Sweden
Joined: 26.03.09
Rank:
Apprentice
Posted on 17-04-09 01:50
ynori7 wrote:
The find method returns an index value, not a boolean. If the search string is not found, it returns "-1".
Code
if line.find('731')>=0:





works perfect, thnx :D


base_dropper@hotmail.com www.demonshalo.com
Author

RE: Some Python Feedback plz

Demons Halo
Member



Posts: 261
Location: Sweden
Joined: 26.03.09
Rank:
Apprentice
Posted on 18-04-09 23:32
aiight.
This will be my first program ever. This is not a challenge or an equation.
My friend who's working as a mod on a game site, they do usually check for ip matches to find cheaters, he asked me in case I could make a short program that can check the file of PLAYER1 and file of PLAYER2 for ip and time matches.

this is how a file looks like: 1. ip.xx.xx.xx 2009-04-06 23:47:00

Player1 file:
1. xx.xx.xx.xx 2009-04-06 23:47:00
2. xx.xx.xx.xx 2009-04-06 20:01:00
3. xx.xx.xx.xx 2009-04-05 21:15:00
4. xx.xx.xx.xx 2009-04-04 15:37:00

player 2:
1. xx.xx.xx.xx 2009-04-18 23:31:00
2. xx.xx.xx.xx 2009-04-18 23:15:00
3. xx.xx.xx.xx 2009-04-18 20:55:00
4. xx.xx.xx.xx 2009-04-18 17:54:00
5. xx.xx.xx.xx 2009-04-18 16:49:00

Now the program menu will have 2 options:
1- Check for date and time matches irrespective of IP for 15 mins range of time between Player1 and Player2.
2- Check for IP matches irrespective of time and date for Player1 and Player2

If the program find any matches it should print them out. That's all

This is easy to do if not for the date matching thing. What syntax should I use to compare the date and time in 2 different files?

You don't have to write any codes, just mention the syntax you see fit this project the best and I'll do the googling Pfft

thnx

//D.H.



base_dropper@hotmail.com www.demonshalo.com
Author

RE: Some Python Feedback plz

ynori7
Member



Posts: 1486
Location: #valhalla
Joined: 08.10.07
Rank:
God
Posted on 19-04-09 00:01
Demons Halo wrote:
This is easy to do if not for the date matching thing. What syntax should I use to compare the date and time in 2 different files?

Well, if all it is is just a date written in the file, you just parse it and check that the years match, then month, then day, then hour, and then just subtract the minutes of one from the other to check whether it's within 15 minutes (i.e. if absolute value of min1-min2<=15).


halls-of-valhalla.org/images/affiliateLogo.png voodoorage.halls-of-valhalla.org/images/smallLogo.png
i537.photobucket.com/albums/ff338/ynori77/archenemysig1.jpg
ynori7 http://halls-of-valhalla.org
Author

RE: Some Python Feedback plz

Demons Halo
Member



Posts: 261
Location: Sweden
Joined: 26.03.09
Rank:
Apprentice
Posted on 19-04-09 00:16
ynori7 wrote:
Well, if all it is is just a date written in the file, you just parse it and check that the years match, then month, then day, then hour, and then just subtract the minutes of one from the other to check whether it's within 15 minutes (i.e. if absolute value of min1-min2<=15).


That was my plan B Pfft
I just though that maybe there is a simpler way of doing it. I'm almost done with the second menu choice.
If only there was a built in command for comparing dates Pfft well.. I guess I'll have to make one myself xD


base_dropper@hotmail.com www.demonshalo.com
Author

RE: Some Python Feedback plz

Demons Halo
Member



Posts: 261
Location: Sweden
Joined: 26.03.09
Rank:
Apprentice
Posted on 19-04-09 19:47
hmm my idea was to have the ip as a key and the date + time as the value of the key, and then compare values in the dictionary. If the date is the same, the program should check the time for matches within a cap of +- 15 mins.

what I've realized is that using a dictionary makes it just 10 times harder than it should be. I'm almost certain there there is a better method for prasing an input string than using a dictionary. I'm going to test assigning a piece of a string to a variable and then comparing variables from 2 different files, but this might not even work :/

any ideas??


base_dropper@hotmail.com www.demonshalo.com
Author

RE: Some Python Feedback plz

ynori7
Member



Posts: 1486
Location: #valhalla
Joined: 08.10.07
Rank:
God
Posted on 19-04-09 20:45
Code
import datetime
>>> t1=datetime.datetime(2007, 3, 3, 22, 20, 11, 443849)
>>> t2=datetime.datetime(2007, 3, 3, 22, 20, 30, 443849)
>>> abs(t2-t1)
datetime.timedelta(0, 19)
>>> abs(t1-t2)
datetime.timedelta(0, 19)
>>> limit=datetime.timedelta(0, 15)
>>> abs(t2-t1)>limit
True



You should be able to figure it out from there.


halls-of-valhalla.org/images/affiliateLogo.png voodoorage.halls-of-valhalla.org/images/smallLogo.png
i537.photobucket.com/albums/ff338/ynori77/archenemysig1.jpg
ynori7 http://halls-of-valhalla.org
Author

RE: Some Python Feedback plz

Demons Halo
Member



Posts: 261
Location: Sweden
Joined: 26.03.09
Rank:
Apprentice
Posted on 19-04-09 23:32
awesome module I must say Grin

thnx and cheers!


base_dropper@hotmail.com www.demonshalo.com
Author

RE: Some Python Feedback plz

Demons Halo
Member



Posts: 261
Location: Sweden
Joined: 26.03.09
Rank:
Apprentice
Posted on 27-04-09 13:07
I'm stuck again Pfft

let's say that I have a list full of numbers.
[0,1,5,6,12,65,66,67,68,123,445,...]

What syntax can I use to get the first 4 consecutive integers? (65,66,67,68)


base_dropper@hotmail.com www.demonshalo.com
Author

RE: Some Python Feedback plz

clone4
Member



Posts: 586
Location: He is back and he's bad!
Joined: 25.11.07
Rank:
Mad User
Posted on 27-04-09 19:12
ynori7 wrote:
Try something like this:
Code
array=[0,1,5,6,12,65,66,67,68,123,445]
i=0
while i<len(array):
    for j in range(i, i+4):
        if (array[j]+1)==array[j+1]:
            continue
        else:
            break
    if j==i+3:
        print str(i)+":"+str(j)
        break
    else:
        i+=j



But seriously, by now you should be able to do this yourself. This isn't that complicated. You can't keep asking for help otherwise you'll never learn. This is the last time I help you unless you have a good question.



nice, but remember to put functions before the loop into a variable, so it gets evaluated only once, and not multiple times. Also dont solve whole problem for the guy, this isn't that hard to code


[img][/img]img164.imageshack.us/img164/5713/perlvl0.jpg

clone4.freehostia.com/ubuntu_3.png
spyware - "They see me trollin'..."
<yaragn> ever seen that movie? The Matrix?
<yaragn> with those green lines of flying text?
<yaragn> *THAT'S* Perl

clone_4@hotmail.com
Author

RE: Some Python Feedback plz

ynori7
Member



Posts: 1486
Location: #valhalla
Joined: 08.10.07
Rank:
God
Posted on 27-04-09 19:25
Demons Halo wrote:
haha that Is not what I had in mind.
I'm tired of using the same syntax over and over again in every program I create, so I thopugh maybe I should get into some advance syntax this time. Creating loops that checks arrays is basic syntax, I'm trying to get into some more "serious" programing, Like the date/time module.

What makes you think that using built-in modules like date/time is more "serious"? Anyone can use a predefined function; it doesn't take any special skills, just a simple google search. And I hate to break it to you, but if you don't like making loops then programming is not for you.

clone4 wrote:
remember to put functions before the loop into a variable, so it gets evaluated only once

Yeah, I know. I wrote it fast and didn't bother with finer details.



halls-of-valhalla.org/images/affiliateLogo.png voodoorage.halls-of-valhalla.org/images/smallLogo.png
i537.photobucket.com/albums/ff338/ynori77/archenemysig1.jpg
ynori7 http://halls-of-valhalla.org
Author

RE: Some Python Feedback plz

Demons Halo
Member



Posts: 261
Location: Sweden
Joined: 26.03.09
Rank:
Apprentice
Posted on 27-04-09 19:41
ynori7 wrote:
Demons Halo wrote:
haha that Is not what I had in mind.
I'm tired of using the same syntax over and over again in every program I create, so I thopugh maybe I should get into some advance syntax this time. Creating loops that checks arrays is basic syntax, I'm trying to get into some more "serious" programing, Like the date/time module.


What makes you think that using built-in modules like date/time is more "serious"? Anyone can use a predefined function; it doesn't take any special skills, just a simple google search. And I hate to break it to you, but if you don't like making loops then programming is not for you.


I'm just trying to practice the syntax so that I can have a wider understanding of the language!
Don't get me wrong, I like creating loops etc. I just want to get more serious and I don't really know where to begin. I'm trying with project Euler, but the problems there are mathematical, so you end up using the same syntax almost all the time with different mathematical equations :/ (a bit of variation can't hurt you Pfft)


base_dropper@hotmail.com www.demonshalo.com
Author

RE: Some Python Feedback plz

ynori7
Member



Posts: 1486
Location: #valhalla
Joined: 08.10.07
Rank:
God
Posted on 27-04-09 19:48
Try the timed challenges, or come up with an idea for a program that will make your life easier. Look up modules as you need them. They're merely useful tools that somebody created, they are not part of the language.


halls-of-valhalla.org/images/affiliateLogo.png voodoorage.halls-of-valhalla.org/images/smallLogo.png
i537.photobucket.com/albums/ff338/ynori77/archenemysig1.jpg
ynori7 http://halls-of-valhalla.org
Author

RE: Some Python Feedback plz

clone4
Member



Posts: 586
Location: He is back and he's bad!
Joined: 25.11.07
Rank:
Mad User
Posted on 27-04-09 19:55
Demons Halo wrote:
I'm just trying to practice the syntax so that I can have a wider understanding of the language!
Don't get me wrong, I like creating loops etc. I just want to get more serious and I don't really know where to begin. I'm trying with project Euler, but the problems there are mathematical, so you end up using the same syntax almost all the time with different mathematical equations :/ (a bit of variation can't hurt you Pfft)


You are repeating 'syntax' all the time, but python's got probably the easiest (understandable to be more exact) syntax amongst high level languages, so there isn't that much to practice(dont want to sound like it's really easy to learn python though). If you want wider understanding of the language, good idea is first to set the aim, is it gonna be sockets, string manipulation or something else. Then take that aboard and start doing some projects, research modules and built in functions, read a quality code, and then write a backdoor, your own encryption algo, or web bruteforcer, the possibilities are endless...



[img][/img]img164.imageshack.us/img164/5713/perlvl0.jpg

clone4.freehostia.com/ubuntu_3.png
spyware - "They see me trollin'..."
<yaragn> ever seen that movie? The Matrix?
<yaragn> with those green lines of flying text?
<yaragn> *THAT'S* Perl



Edited by clone4 on 27-04-09 19:58
clone_4@hotmail.com
Author

RE: Some Python Feedback plz

Demons Halo
Member



Posts: 261
Location: Sweden
Joined: 26.03.09
Rank:
Apprentice
Posted on 27-04-09 23:16
clone4 wrote:
You are repeating 'syntax' all the time, but python's got probably the easiest (understandable to be more exact) syntax amongst high level languages, so there isn't that much to practice(dont want to sound like it's really easy to learn python though). If you want wider understanding of the language, good idea is first to set the aim, is it gonna be sockets, string manipulation or something else. Then take that aboard and start doing some projects, research modules and built in functions, read a quality code, and then write a backdoor, your own encryption algo, or web bruteforcer, the possibilities are endless...


That's why I love python, the short and easy syntax. Ideas like backdorrs/web bruteforcer are the type of things I'm looking for Grin Awesome advice thnx.

@ynori7
well I find it easy to work with python, all I need is a couple of creative ideas to work on that's all.
I've been doing timed challenges and Project Euler for a long time now, so I got kind a bored. That's why I went looking for ways to shrink my codes in order to make them shorter & faster using module syntax Pfft



base_dropper@hotmail.com www.demonshalo.com
Page 2 of 2 < 1 2