跳至主要內容
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?

4563博客

全新的繁體中文 WordPress 網站
  • 首頁
  • u-file利用
未分類
4 2 月 2020

u-file利用

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>&nbsp&nbsp<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>&nbsp&nbsp<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

文章導覽

上一篇文章
下一篇文章

AD

其他操作

  • 登入
  • 訂閱網站內容的資訊提供
  • 訂閱留言的資訊提供
  • WordPress.org 台灣繁體中文

51la

4563博客

全新的繁體中文 WordPress 網站
返回頂端
本站採用 WordPress 建置 | 佈景主題採用 GretaThemes 所設計的 Memory
4563博客
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?
在這裡新增小工具