This post is by a banned member (hugs) - Unhide
OP 26 December, 2021 - 01:38 AM
(This post was last modified: 26 December, 2021 - 01:40 AM by hugs. Edited 2 times in total.)
Reply
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
26 December, 2021 - 01:39 AM
Reply
This post is by a banned member (hugs) - Unhide
OP 26 December, 2021 - 01:41 AM
Reply
(26 December, 2021 - 01:39 AM)polo Wrote: Show Moreadd 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
26 December, 2021 - 01:43 AM
(This post was last modified: 26 December, 2021 - 01:43 AM by polo. Edited 1 time in total.)
Reply
(26 December, 2021 - 01:41 AM)hugs Wrote: Show More (26 December, 2021 - 01:39 AM)polo Wrote: Show Moreadd 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
OP 26 December, 2021 - 01:46 AM
Reply
(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 Moreadd 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
26 December, 2021 - 01:53 PM
Reply
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
28 December, 2021 - 02:49 AM
Reply
(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 Moreif 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
OP 28 December, 2021 - 05:45 AM
Reply
(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 MoreWhat 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
|