Skip to content
This repository has been archived by the owner on Jul 3, 2024. It is now read-only.

自适应http与https,密码加密传输 #21

Merged
merged 3 commits into from
Feb 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ function pwdChallenge()
foreach ($pwdCfg as $line) {
$singleConfig = explode(' ', $line);
$targetFolder = $singleConfig[0];/*获得每行配置的目标目录*/
$targetPwd = trim($singleConfig[1]);/*获得每行目录对应的md5密码*/
$targetPwd = md5(trim($singleConfig[1]));/*获得每行目录对应的md5密码*/
if (empty($targetFolder)) continue;/*如果配置目录为空就跳过,防止匹配bug*/
if (stripos($currentPath, $targetFolder) === 0) {/*当前目录能匹配上目标目录,受密码保护*/
$folderMd5 = md5($targetFolder);/*得到目标foldermd5*/
Expand Down Expand Up @@ -803,7 +803,7 @@ function queueChecker($statu, $waiting = false, $id = false)
$pwdRqFolder = @$_POST['requestfolder'];
$passwd = @$_POST['password'];
if (!empty($pwdRqFolder)) {
$_SESSION['passwd'][$pwdRqFolder] = md5($passwd);/*提交并储存密码*/
$_SESSION['passwd'][$pwdRqFolder] = $passwd;/*提交并储存密码*/
}
@session_write_close();
/*Password Receiver End*/
Expand Down
42 changes: 24 additions & 18 deletions template.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport" />
<link href="https://fastly.jsdelivr.net/gh/SomeBottle/OdIndex@3.2/assets/style.css" rel="stylesheet">
<link href='https://fastly.jsdelivr.net/gh/SomeBottle/OdIndex@1.2.6.2/assets/woff.css' rel='stylesheet'>
<link href='https://fastly.jsdelivr.net/npm/github-markdown-css/github-markdown-light.css' rel='stylesheet'>
<link rel="stylesheet" href="https://fastly.jsdelivr.net/npm/prismjs@1.17.1/themes/prism.min.css">
<link href="//fastly.jsdelivr.net/gh/SomeBottle/OdIndex@3.2/assets/style.css" rel="stylesheet">
<link href='//fastly.jsdelivr.net/gh/SomeBottle/OdIndex@1.2.6.2/assets/woff.css' rel='stylesheet'>
<link href='//fastly.jsdelivr.net/npm/github-markdown-css/github-markdown-light.css' rel='stylesheet'>
<link rel="stylesheet" href="//fastly.jsdelivr.net/npm/prismjs@1.17.1/themes/prism.min.css">
<title>OdIndex - /{[Path]}</title>
</head>

Expand All @@ -27,9 +27,9 @@
</div>
</div>
</body>
<script src="https://fastly.jsdelivr.net/npm/prismjs/prism.min.js"></script>
<script src='https://fastly.jsdelivr.net/npm/markdown-it@latest/dist/markdown-it.min.js'></script>
<script src="https://fastly.jsdelivr.net/gh/SomeBottle/othumb.js@0.8/othumb.m.js"></script>
<script src="//fastly.jsdelivr.net/npm/prismjs/prism.min.js"></script>
<script src='//fastly.jsdelivr.net/npm/markdown-it@latest/dist/markdown-it.min.js'></script>
<script src="//fastly.jsdelivr.net/gh/SomeBottle/othumb.js@0.8/othumb.m.js"></script>
<script>
var readmefile = "{[ReadmeFile]}";

Expand Down Expand Up @@ -96,9 +96,9 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport" />
<link href="https://fastly.jsdelivr.net/gh/SomeBottle/OdIndex@3.2/assets/style.css" rel="stylesheet">
<link href='https://fastly.jsdelivr.net/npm/github-markdown-css/github-markdown-light.css' rel='stylesheet'>
<link rel="stylesheet" href="https://fastly.jsdelivr.net/npm/prismjs@1.17.1/themes/prism.min.css">
<link href="//fastly.jsdelivr.net/gh/SomeBottle/OdIndex@3.2/assets/style.css" rel="stylesheet">
<link href='//fastly.jsdelivr.net/npm/github-markdown-css/github-markdown-light.css' rel='stylesheet'>
<link rel="stylesheet" href="//fastly.jsdelivr.net/npm/prismjs@1.17.1/themes/prism.min.css">
<title>OdIndex Preview</title>
</head>

Expand Down Expand Up @@ -158,7 +158,7 @@
<div class='previewtext markdown-body' id='md'>{[FileContent]}</div>
</div>
</div>
<script src='https://fastly.jsdelivr.net/npm/markdown-it@latest/dist/markdown-it.min.js'></script>
<script src='//fastly.jsdelivr.net/npm/markdown-it@latest/dist/markdown-it.min.js'></script>
<script>
document.getElementById('md').innerHTML = window.markdownit().render(document.getElementById('md').innerHTML);
</script>
Expand All @@ -170,7 +170,7 @@
</div>
</div>
</div>
<script src="https://fastly.jsdelivr.net/npm/prismjs/prism.min.js"></script>
<script src="//fastly.jsdelivr.net/npm/prismjs/prism.min.js"></script>
<script>
Prism.highlightAllUnder(document.getElementById('codes'));
</script>
Expand All @@ -188,9 +188,15 @@ <h2 style='margin-top:0;'>此预览需要前往Office</h2>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport" />
<link href="https://fastly.jsdelivr.net/gh/SomeBottle/OdIndex@3.2/assets/style.css" rel="stylesheet">
<link href='https://fastly.jsdelivr.net/npm/github-markdown-css/github-markdown-light.css' rel='stylesheet'>
<link rel="stylesheet" href="https://fastly.jsdelivr.net/npm/prismjs@1.17.1/themes/prism.min.css">
<link href="//fastly.jsdelivr.net/gh/SomeBottle/OdIndex@3.2/assets/style.css" rel="stylesheet">
<link href='//fastly.jsdelivr.net/npm/github-markdown-css/github-markdown-light.css' rel='stylesheet'>
<link rel="stylesheet" href="//fastly.jsdelivr.net/npm/prismjs@1.17.1/themes/prism.min.css">
<script src='//fastly.jsdelivr.net/npm/js-md5@0.7.3/build/md5.min.js'></script>
<script>
function md5zme() {
document.getElementById('password').value = md5(md5(document.getElementById('password').value))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

两层甚至3层md5对于前端密码hash而言跟1层都是差不多不安全的
https://cmd5.com 这样的彩虹表早就算出了许多常见密码排列组合的hash
建议直接hmacsha256
提请四叶信安底层壬上壬上海贵族 FSF EFF 精神会员杨博文阁下 @yangbowen 立即评估如何在前端层正确地hash提交给后端的明文密码

}
</script>
<title>OdIndex - /{[Path]}</title>
</head>

Expand All @@ -204,12 +210,12 @@ <h2 style='margin-top:0;'>此预览需要前往Office</h2>
<div style='min-width:300px'>
<h2>输入密码以继续</h2>
<div class='passwordform'>
<form action="#" method="post" style="display: flex;flex: 1;">
<input class='passwordinput' type="password" name="password" placeholder="password"></input><input type="hidden" name="requestfolder" value="{[FolderMD5]}" /><input type='submit' class='submitbtn' value='Submit'></input>
<form action="#" method="post" style="display: flex;flex: 1;" onsubmit="md5zme()">
<input class='passwordinput' type="password" name="password" id="password" placeholder="password"></input><input type="hidden" name="requestfolder" value="{[FolderMD5]}" /><input type='submit' class='submitbtn' value='Submit'></input>
</form>
</div>
</div>
</div>
</div>
</body>
{{PasswordPageEnd}}
{{PasswordPageEnd}}