python code to generate password list
Question: I am researching wireless security and trying to write a python script to
generate passwords, not random, but a dictionary of hex numbers. The letters
need to be capital, and it has to go from 12 characters to 20 characters. I
went from 11 f's to 20 f's, this seems like it would meet the requirements. I
then tried to place them in a text file. After I made the file, I chmod'ed it
to 777 and then clicked run. It has been a few minutes, but I cannot tell if
it is working or not. I am running it in kali right now, on a 64 bit core i3
with 8gb of ram. I'm not sure how long it would be expected to take, but this
is my code, let me know if it looks right please:

    
    
    # generate 10 to 32 character password list using hex numbers, 0-9 A-F
    def gen_pwd(x):
        x = range(17592186044415 -295147905179352830000)
        def toHex(dec):
            x = (dec % 16)
            digits = "0123456789ABCDEF"
            rest = dec / 16
            if (rest == 0):
                return digits[x]
            return toHex(rest) + digits[x]
    
        for x in range(x):
            print toHex(x) 
        f = open(/root/Home/sdnlnk_pwd.txt)
        print f
        value = x
        string = str(value)
        f.write(string) 
    
    gen_pwd
    


Answer: how bout just

    
    
    password = hex(random.randint(1000000,100000000))[2:]
    

or

    
    
    pw_len = 12
    my_alphabet = "1234567890ABCDEF"
    password = "".join(random.choice(my_alphabet) for _ in range(pw_len))
    

or what maybe closer to what you are trying to do

    
    
    struct.pack("Q",12365468987654).encode("hex").upper()
    

basically you are overcomplicating a very simple task

to do exactly what you are asking you can simplify it

    
    
    import itertools, struct
    
    def int_to_chars(d):
        '''
        step 1: break into bytes
        '''
        while d > 0: # while we have not consumed
           yield struct.pack("B",d&0xFF) # decode char
           d>>=8 # shift right one byte
        yield "" # a terminator just in case its empty
    
    def to_password(d):
        # this will convert an arbitrarily large number to a password
        return "".join(int_to_chars(d)).encode("hex").upper()  
        # you could probably just get away with `return hex(d)[2:]`
    
    def all_the_passwords(minimum,maximum):
        #: since our numbers are so big we need to resort to some trickery
        all_pw = itertools.takewhile(lambda x:x<maximum,
                                     itertools.count(minimum))
        for pw in all_pw:
            yield to_password(pw)
    
    all_passwords = all_the_passwords( 0xfffffffffff ,0xffffffffffffffffffff)
    #this next bit is gonna take a while ... go get some coffee or something
    for pw in all_passwords:
        print pw
    #you will be waiting for it to finish for a very long time ... but it will get there
    

