Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
Hackthon-StatiCrypt
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shijie Xiao
Hackthon-StatiCrypt
Commits
2f4f1f35
Commit
2f4f1f35
authored
Sep 23, 2017
by
lance
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crypt
parent
ff5c7359
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
160 deletions
+43
-160
index.html
examples/dist/index.html
+3
-153
webpack-hello.plugin.js
webpack-hello.plugin.js
+39
-6
webpack.config.js
webpack.config.js
+1
-1
No files found.
examples/dist/index.html
View file @
2f4f1f35
...
...
@@ -3,162 +3,12 @@
<head>
<meta
charset=
"UTF-8"
>
<title>
Example Index
</title>
<style>
.staticrypt-hr
{
margin-top
:
20px
;
margin-bottom
:
20px
;
border
:
0
;
border-top
:
1px
solid
#eee
;
}
.staticrypt-page
{
width
:
360px
;
padding
:
8%
0
0
;
margin
:
auto
;
box-sizing
:
border-box
;
}
.staticrypt-form
{
position
:
relative
;
z-index
:
1
;
background
:
#FFFFFF
;
max-width
:
360px
;
margin
:
0
auto
100px
;
padding
:
45px
;
text-align
:
center
;
box-shadow
:
0
0
20px
0
rgba
(
0
,
0
,
0
,
0.2
),
0
5px
5px
0
rgba
(
0
,
0
,
0
,
0.24
);
}
.staticrypt-form
input
{
outline
:
0
;
background
:
#f2f2f2
;
width
:
100%
;
border
:
0
;
margin
:
0
0
15px
;
padding
:
15px
;
box-sizing
:
border-box
;
font-size
:
14px
;
}
.staticrypt-form
.staticrypt-decrypt-button
{
text-transform
:
uppercase
;
outline
:
0
;
background
:
#4CAF50
;
width
:
100%
;
border
:
0
;
padding
:
15px
;
color
:
#FFFFFF
;
font-size
:
14px
;
cursor
:
pointer
;
}
.staticrypt-form
.staticrypt-decrypt-button
:hover
,
.staticrypt-form
.staticrypt-decrypt-button
:active
,
.staticrypt-form
.staticrypt-decrypt-button
:focus
{
background
:
#43A047
;
}
.staticrypt-html
{
height
:
100%
;
}
.staticrypt-body
{
margin-bottom
:
1em
;
background
:
#76b852
;
/* fallback for old browsers */
background
:
-webkit-linear-gradient
(
right
,
#76b852
,
#8DC26F
);
background
:
-moz-linear-gradient
(
right
,
#76b852
,
#8DC26F
);
background
:
-o-linear-gradient
(
right
,
#76b852
,
#8DC26F
);
background
:
linear-gradient
(
to
left
,
#76b852
,
#8DC26F
);
font-family
:
"Arial"
,
sans-serif
;
-webkit-font-smoothing
:
antialiased
;
-moz-osx-font-smoothing
:
grayscale
;
}
.staticrypt-instructions
{
margin-top
:
-1em
;
margin-bottom
:
1em
;
}
.staticrypt-title
{
font-size
:
1.5em
;
}
.staticrypt-footer
{
position
:
fixed
;
height
:
20px
;
font-size
:
16px
;
padding
:
2px
;
bottom
:
0
;
left
:
0
;
right
:
0
;
margin-bottom
:
0
;
}
.staticrypt-footer
p
{
margin
:
2px
;
text-align
:
center
;
float
:
right
;
}
.staticrypt-footer
a
{
text-decoration
:
none
;
}
</style>
</head>
<body
class=
"staticrypt-body"
>
<div
class=
"staticrypt-page"
>
<div
class=
"staticrypt-form"
>
<div
class=
"staticrypt-instructions"
>
<p
class=
"staticrypt-title"
>
Protected Page
</p>
<p>
Enter "test" to unlock the page
</p>
</div>
<hr
class=
"staticrypt-hr"
>
<form
id=
"staticrypt-form"
action=
"#"
method=
"post"
>
<input
id=
"staticrypt-password"
type=
"password"
name=
"password"
placeholder=
"passphrase"
autofocus
/>
<input
type=
"submit"
class=
"staticrypt-decrypt-button"
value=
"DECRYPT"
/>
</form>
</div>
</div>
<footer
class=
"staticrypt-footer"
>
<p
class=
"pull-right"
>
Created with
<a
href=
"https://robinmoisson.github.io/staticrypt"
>
StatiCrypt
</a></p>
</footer>
<script
src=
"bundle.js"
/>
<
script
src
=
"https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/crypto-js.min.js"
integrity
=
"sha384-lp4k1VRKPU9eBnPePjnJ9M2RF3i7PC30gXs70+elCVfgwLwx1tv5+ctxdtwxqZa7"
crossorigin
=
"anonymous"
>
</script>
<script>
document
.
getElementById
(
'staticrypt-form'
).
addEventListener
(
'submit'
,
function
(
e
)
{
e
.
preventDefault
();
var
passphrase
=
document
.
getElementById
(
'staticrypt-password'
).
value
,
encryptedMsg
=
'bf73a9eb1c0ef239c83d262470f6a1a55b024a867a41199f73a33b82d73f6855U2FsdGVkX1/GeUxTnFMh1/3gx6bj1Cb4/bQxA/2toJZe8tX6H4azBaCfva11oo9Klj4NIYglL2ln6tQdBGEFHLCRy1ib6Fd89heNRoE30ua/AN0jvfxGP81ZOOzjAeSGb3gDUqOpgobXNz0rTw1z3cl++Sj9yrrOePbhmu7tPEJhz9NT50iAakdHNqm4fOjU4UiJFYBRcKERg0rXG9mHFg=='
,
encryptedHMAC
=
encryptedMsg
.
substring
(
0
,
64
),
encryptedHTML
=
encryptedMsg
.
substring
(
64
),
decryptedHMAC
=
CryptoJS
.
HmacSHA256
(
encryptedHTML
,
CryptoJS
.
SHA256
(
passphrase
)).
toString
();
// var bytes = CryptoJS.AES.decrypt(ciphertext.toString(), '123');
// var plaintext = bytes.toString(CryptoJS.enc.Utf8);
<body>
if
(
decryptedHMAC
!==
encryptedHMAC
)
{
alert
(
'Bad passphrase !'
);
return
;
}
<div
id=
"root"
></div>
var
plainHTML
=
CryptoJS
.
AES
.
decrypt
(
encryptedHTML
,
passphrase
).
toString
(
CryptoJS
.
enc
.
Utf8
);
<script
src=
"bundle.js"
></script>
document
.
write
(
plainHTML
);
document
.
close
();
});
</script>
</body>
</html>
webpack-hello.plugin.js
View file @
2f4f1f35
...
...
@@ -11,21 +11,54 @@ class HelloPlugin {
}
apply
(
compiler
)
{
const
options
=
this
.
options
const
{
passphrase
}
=
this
.
options
compiler
.
plugin
(
"compilation"
,
(
compilation
)
=>
{
compilation
.
plugin
(
"optimize-assets"
,
(
assets
,
callback
)
=>
{
let
pattern
=
/
[^\s]
*
\.
js$/
;
async
.
forEach
(
Object
.
keys
(
assets
),
(
file
,
cb
)
=>
{
const
asset
=
assets
[
file
];
let
content
=
asset
.
source
();
var
ciphertext
=
CryptoJS
.
AES
.
encrypt
(
content
.
toString
(),
'123'
).
toString
();
const
unencrypted
=
asset
.
source
().
toString
(),
encrypted
=
CryptoJS
.
AES
.
encrypt
(
unencrypted
,
passphrase
),
hmac
=
CryptoJS
.
HmacSHA256
(
encrypted
.
toString
(),
CryptoJS
.
SHA256
(
passphrase
)).
toString
(),
encryptedMsg
=
hmac
+
encrypted
;
// var bytes = CryptoJS.AES.decrypt(ciphertext.toString(), '123');
// var plaintext = bytes.toString(CryptoJS.enc.Utf8);
assets
[
file
]
=
new
ConcatSource
(
ciphertext
);
let
ciphertext
=
`
function test(){
var passphrase = prompt("请输入密码", "");
let content = "
${
encryptedMsg
}
";
encryptedHMAC = content.substring(0, 64),
encryptedHTML = content.substring(64),
decryptedHMAC = CryptoJS.HmacSHA256(encryptedHTML, CryptoJS.SHA256(passphrase)).toString()
if (decryptedHMAC !== encryptedHMAC) {
alert('Bad passphrase !')
return
}
const plainHTML = CryptoJS.AES.decrypt(encryptedHTML, passphrase).toString(CryptoJS.enc.Utf8);
eval(plainHTML);
}
var flag = false;
var script = document.createElement('script');
script.src = 'https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js';
script.addEventListener("load",function(){
flag ? test() : flag = true;
})
document.body.appendChild(script);
var script1 = document.createElement('script');
script1.src = 'https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/crypto-js.min.js';
document.body.appendChild(script1);
script1.addEventListener("load",function(){
flag ? test() : flag = true;
})
`
assets
[
file
]
=
new
ConcatSource
(
ciphertext
);
cb
();
},
callback
);
});
...
...
webpack.config.js
View file @
2f4f1f35
...
...
@@ -95,7 +95,7 @@ module.exports = {
// 当模块热替换(HMR)时在浏览器控制台输出对用户更友好的模块名字信息
new
HelloPlugin
({
banner
:
"hash:[hash], chunkhash:[chunkhash], name:[name], filebase:[filebase], query:[query], file:[file]
"
passphrase
:
"strikingly
"
})
],
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment