yjsx86 大佬有话说 :
u-file利用
之前注册了u-file但是一直没用
今天要把其中一个文件分享给朋友, 久没用忘了具体位置, 然后登录flashfxp找文件然后拼接url再给朋友
感觉有点麻烦 就产生了这个脚本
具体作用呢就是遍历文件, 然后生成html上传
效果见:http://files.baicailou.com
import ftplib
import re
addr_ftp = "box.u-file.cn"
# 用户名
username = "?????????????????"
# 密码
password = "?????????????????"
ftp = ftplib.FTP(addr_ftp)
ftp.encoding = "utf-8"
ftp.login(username, password)
print(ftp.welcome)
tlp = ”'<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="Expires" content="0">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-control" content="no-cache">
<meta http-equiv="Cache" content="no-cache">
<title>TEST</title>
<style>
*{
color: #000000;
}
</style>
</head>
<body>
{{content}}
</body>
</html>”’
def upload_index(html):
t = re.sub(r"{{content}}", html, tlp)
with open("temp", "w", encoding="utf-8") as f:
f.truncate()
f.write(t)
with open("temp", "rb") as fp:
ftp.storbinary("STOR index.html",fp, 1024)
print(f"{ftp.pwd()} 上传index.html成功!")
def walk(newpath="."):
ftp.cwd(newpath)
dirs = []
files = []
curpath = ftp.pwd()
if len(curpath.split("/")) == 2:
p = f'<a href="/index.html">返回上一级</a>  <a href="/index.html">首页</a><br>n’
else:
l = curpath.split("/")
sub = ‘/’.join(l[:len(l)-1])
p = f'<a href="{sub}/index.html">返回上一级</a>  <a href="/index.html">首页</a><br>n’
for item in ftp.nlst():
if item == "index.html":
ftp.delete(item)
elif ftp.size(item):
files.append(item)
else:
dirs.append(item)
walk(item)
for fi in files:
path = curpath + fi if curpath == "/" else curpath + "/" + fi
p += f'<a href="{path}">{fi}</a><br>n’
for di in dirs:
path = curpath + di if curpath == "/" else curpath + "/" + di
p += f'<a href="{path}/index.html">{di}</a><br>n’
upload_index(p)
ftp.cwd("..")
if __name__ == "__main__":
try:
walk()
except Exception as e:
print(e)
finally:
ftp.quit()
ftp.close()
etc 大佬有话说 :
谢谢大佬的脚本,马上试试去
chxin 大佬有话说 :
还存活呢 zsbd:lol