Navigation X
ALERT
Click here to register with a few steps and explore all our cool stuff we have to offer!



   2600

Need Help With Python Combo Editor

by hugs - 26 December, 2021 - 01:38 AM
This post is by a banned member (hugs) - Unhide
hugs  
Supreme
156
Posts
46
Threads
4 Years of service
#1
(This post was last modified: 26 December, 2021 - 01:40 AM by hugs. Edited 2 times in total.)
Ok, so I'm trying to make a fast editor that takes passwords from a password list, and users from a username list, and appends every password in the list to each username

for example:
 
Code:
user1:pass1
user1:pass2
user1:pass3
user2:pass1
user2:pass2
user2:pass3
...

And so on, so forth.


I easily made the folowing code that WORKS, however it is painfully slow when I need to generate a list that will be 9,000,000 lines large.

My current code:
 
Code:
usernames = open("Usernames.txt").read().splitlines()

passwords = open("Passwords.txt").read().splitlines()

for username in usernames:
    for password in passwords:
        with open("Combo.txt", "a+") as combofile:
            combofile.write(f"{username}:{password}\n")

This code again works just fine, however it is PAINFULLY slow when the end result (the combo) is expected to be around 9,000,000 lines. 
I attempted to add multithreading, however the text file became way too large, had messed up lines, duplicates, etc.

If there is any way I can speed this process up drastically, please let me know!
Discord: blunt.s
telegram: inflicting
This post is by a banned member (polo) - Unhide
polo  
Supreme
993
Posts
203
Threads
5 Years of service
#2
add threading
This post is by a banned member (hugs) - Unhide
hugs  
Supreme
156
Posts
46
Threads
4 Years of service
#3
(26 December, 2021 - 01:39 AM)polo Wrote: Show More
add threading

if you bothered to read the entire thing, I stated that I did. It didn't work out with the thread-base I used, and was wondering if there was an alternative I haven't taken into account.
Discord: blunt.s
telegram: inflicting
This post is by a banned member (polo) - Unhide
polo  
Supreme
993
Posts
203
Threads
5 Years of service
#4
(This post was last modified: 26 December, 2021 - 01:43 AM by polo. Edited 1 time in total.)
(26 December, 2021 - 01:41 AM)hugs Wrote: Show More
(26 December, 2021 - 01:39 AM)polo Wrote: Show More
add threading

if you bothered to read the entire thing, I stated that I did. It didn't work out with the thread-base I used, and was wondering if there was an alternative I haven't taken into account.

What was the issue with threading, thats probably what I should have asked, any specific errors? or just the ones you mentioned
This post is by a banned member (hugs) - Unhide
hugs  
Supreme
156
Posts
46
Threads
4 Years of service
#5
(26 December, 2021 - 01:43 AM)polo Wrote: Show More
(26 December, 2021 - 01:41 AM)hugs Wrote: Show More
(26 December, 2021 - 01:39 AM)polo Wrote: Show More
add threading

if you bothered to read the entire thing, I stated that I did. It didn't work out with the thread-base I used, and was wondering if there was an alternative I haven't taken into account.

What was the issue with threading, thats probably what I should have asked, any specific errors? or just the ones you mentioned

The threading system I used is fundamentally correct, however it did not properly append the lines to the output file. I don't need them in any specific order, I just need them all to be appended properly with no duplicates, no blank lines, nothing other than the intended user:pass
Discord: blunt.s
telegram: inflicting
This post is by a banned member (ZeroTolerance) - Unhide
147
Posts
19
Threads
5 Years of service
#6
it takes so much time because you open Combo.txt in every line, you can do something like this instead :
 
Code:
 
usernames = open("Usernames.txt", "r")
passwords = open("Passwords.txt", "r")
combofile = open("Combo.txt", "a+")

for user in usernames:
    for passw in passwords:
        combofile.write(user.strip() + ":" + passw.strip() + "\n")
        
usernames.close()
passwords.close()
combofile.close()
This post is by a banned member (clap) - Unhide
clap  
Godlike
516
Posts
134
Threads
6 Years of service
#7
(26 December, 2021 - 01:46 AM)hugs Wrote: Show More
(26 December, 2021 - 01:43 AM)polo Wrote: Show More
(26 December, 2021 - 01:41 AM)hugs Wrote: Show More
if you bothered to read the entire thing, I stated that I did. It didn't work out with the thread-base I used, and was wondering if there was an alternative I haven't taken into account.

What was the issue with threading, thats probably what I should have asked, any specific errors? or just the ones you mentioned

The threading system I used is fundamentally correct, however it did not properly append the lines to the output file. I don't need them in any specific order, I just need them all to be appended properly with no duplicates, no blank lines, nothing other than the intended user:pass

Then you probably implemented the threading wrong.
As you're using a dataset, you shouldn't (and can't) loop
through it while changing it. Meaning, in each thread
it shouldn't be a for-loop, but a while-loop. I'll show you what
I mean.
 
Code:
 
usernames = [
    'user1',
    'user2'
]
passwords = [
    'pass1',
    'pass2'
]
combolist = {
    (
        _user,
        _pass
    )
    for _user, _pass in zip(
        usernames,
        passwords
    )
}

# Using a set as we don't want duplicates

def worker():
    while True:
        try:
            username, password = combolist.pop()

            with open('output.txt', 'a') as file:
                file.write(f'{username}:{password}\n')
                file.close()

        except KeyError:
            break

If you thread this, it'll work fine as we aren't using any non thread-safe operations.

Hope this thought you anything,
Always confirm via PM before dealing with me.
This post is by a banned member (hugs) - Unhide
hugs  
Supreme
156
Posts
46
Threads
4 Years of service
#8
(28 December, 2021 - 02:49 AM)iclapcheeks Wrote: Show More
(26 December, 2021 - 01:46 AM)hugs Wrote: Show More
(26 December, 2021 - 01:43 AM)polo Wrote: Show More
What was the issue with threading, thats probably what I should have asked, any specific errors? or just the ones you mentioned

The threading system I used is fundamentally correct, however it did not properly append the lines to the output file. I don't need them in any specific order, I just need them all to be appended properly with no duplicates, no blank lines, nothing other than the intended user:pass

Then you probably implemented the threading wrong.
As you're using a dataset, you shouldn't (and can't) loop
through it while changing it. Meaning, in each thread
it shouldn't be a for-loop, but a while-loop. I'll show you what
I mean.
 
Code:
 
usernames = [
    'user1',
    'user2'
]
passwords = [
    'pass1',
    'pass2'
]
combolist = {
    (
        _user,
        _pass
    )
    for _user, _pass in zip(
        usernames,
        passwords
    )
}

# Using a set as we don't want duplicates

def worker():
    while True:
        try:
            username, password = combolist.pop()

            with open('output.txt', 'a') as file:
                file.write(f'{username}:{password}\n')
                file.close()

        except KeyError:
            break

If you thread this, it'll work fine as we aren't using any non thread-safe operations.

Hope this thought you anything,

Thank you! Threading has always been a bit tough to wrap my head around, especially when dealing with non thread-safe operations (such as print statements). I'll use this as a reference!
Discord: blunt.s
telegram: inflicting

Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
or
Sign in
Already have an account? Sign in here.


Forum Jump:


Users browsing this thread: 1 Guest(s)