gpt4 book ai didi

python - 逐渐增加字母表中的字母

转载 作者:行者123 更新时间:2023-11-30 22:05:28 24 4
gpt4 key购买 nike

所以我一直在尝试为 php 表单创建一个简单的暴力破解脚本(当然是在我自己的本地网络服务器上),它本质上是通过 for 循环将数据输入到列表中来工作的。问题就在这里;如果我的列表是: list = ['a','b','c','d','e','f','g'] 并且我的 for 循环看起来像这个:

for i in list:
r = request.post(url, values) #posts the values
if 'id=correct' in open('output.txt').read(): #check if it works
print("logged in")
#if it works, it would print this, if not,
#it will retry with the next element in the list

问题是,这仅适用于一个字母的密码(因为它只在列表中循环一次)。我的问题是;我如何得到它,以便一旦它循环遍历列表一次,它将再次启动 for 循环,除了列表中的两个元素(即 aa、ab、ac、ad、ae、ef 等)

谢谢!

最佳答案

您可以通过递增数字并将其转换为基数 7(列表的长度)来将此视为基数转换问题:

def convert(n, lst):
s = ''
while True:
s = lst[n % len(lst)] + s
if n < len(lst):
break
n = n // len(lst) - 1
return s

这样:

lst = ['a','b','c','d','e','f','g']
print(convert(0, lst))
print(convert(6, lst))
print(convert(7, lst))
print(convert(8, lst))
print(convert(55, lst))
print(convert(56, lst))
print(convert(57, lst))

输出:

a
g
aa
ab
gg
aaa
aab

关于python - 逐渐增加字母表中的字母,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53007574/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com