Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
HTTP.sh
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
7
Issues
7
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Laura x Dominika x Patrycja
HTTP.sh
Commits
03f39e3d
Commit
03f39e3d
authored
Jun 02, 2020
by
Dominika Liberda
💽
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added r[ip], r[proto] and IP logging
parent
09008f78
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
14 deletions
+24
-14
config/master.sh
config/master.sh
+5
-0
http.sh
http.sh
+4
-4
src/account.sh
src/account.sh
+0
-3
src/mime.sh
src/mime.sh
+0
-1
src/server.sh
src/server.sh
+15
-6
No files found.
config/master.sh
View file @
03f39e3d
...
...
@@ -21,3 +21,8 @@ cfg[title]='ddd defies development'
cfg[php_enabled]
=
true
cfg[python_enabled]
=
true
# by default, those logs are placed in the main directory - change it to /var/log/_name_ for production
cfg[log_http]
=
'log_http'
cfg[log_https]
=
'log_https'
cfg[log_misc]
=
'log'
http.sh
View file @
03f39e3d
...
...
@@ -11,14 +11,14 @@ echo "HTTP.sh"
if
[[
${
cfg
[ssl]
}
==
true
]]
;
then
echo
"listening on port
${
cfg
[port]
}
(HTTP) and
${
cfg
[ssl_port]
}
(HTTPS)"
ncat
-
l
-p
${
cfg
[port]
}
-c
./src/server.sh
-k
&
ncat
-
v
-l
-p
${
cfg
[port]
}
-c
./src/server.sh
-k
2>>
${
cfg
[log_http]
}
&
if
[[
${
cfg
[ssl_key]
}
!=
''
&&
${
cfg
[ssl_cert]
}
!=
''
]]
;
then
ncat
-
l
-p
${
cfg
[ssl_port]
}
-c
./src/server.sh
-k
--ssl
--ssl-cert
${
cfg
[ssl_cert]
}
--ssl-key
${
cfg
[ssl_key
]
}
ncat
-
v
-l
-p
${
cfg
[ssl_port]
}
-c
./src/server.sh
-k
--ssl
--ssl-cert
${
cfg
[ssl_cert]
}
--ssl-key
${
cfg
[ssl_key]
}
2>>
${
cfg
[log_https
]
}
else
ncat
-
l
-p
${
cfg
[ssl_port]
}
-c
./src/server.sh
-k
--ssl
ncat
-
v
-l
-p
${
cfg
[ssl_port]
}
-c
./src/server.sh
-k
--ssl
2>>
${
cfg
[log_https]
}
fi
else
echo
"listening on port
${
cfg
[port]
}
(HTTP)"
ncat
-
l
-p
${
cfg
[port]
}
-c
./src/server.sh
-k
ncat
-
v
-l
-p
${
cfg
[port]
}
-c
./src/server.sh
-k
2>>
${
cfg
[log_http]
}
fi
src/account.sh
View file @
03f39e3d
...
...
@@ -23,7 +23,6 @@ function register() {
# login(username, password)
function
login
()
{
local
username
=
$(
echo
-ne
$(
echo
"
$1
"
|
sed
-E
's/%/\\x/g'
))
echo
$1
$username
>
/dev/stderr
IFS
=
':'
local
user
=(
$(
grep
"
$username
:"
secret/users.dat
)
)
unset
IFS
...
...
@@ -42,7 +41,6 @@ function login() {
# login_simple(base64)
function
login_simple
()
{
local
data
=
$(
echo
$3
|
base64
-d
)
echo
$3
>
/dev/stderr
local
password
=
$(
echo
$data
|
sed
-E
's/^(.*)\://'
)
local
login
=
$(
echo
$data
|
sed
-E
's/\:(.*)$//'
)
...
...
@@ -51,7 +49,6 @@ function login_simple() {
unset
IFS
if
[[
$(
echo
-n
$password
${
user
[2]
}
|
sha256sum
|
cut
-c
1-64
)
==
${
user
[1]
}
]]
;
then
r[authorized]
=
true
echo
"nay"
>
/dev/stderr
else
r[authorized]
=
false
fi
...
...
src/mime.sh
View file @
03f39e3d
...
...
@@ -15,7 +15,6 @@
function
get_mime
()
{
local
file
=
$@
local
mime
=
$(
file
--mime-type
-b
$file
)
echo
$file
$mime
>
/dev/stderr
if
[[
$file
==
*
".htm"
||
$file
==
*
".html"
]]
;
then
content_type
=
"text/html"
return
0
...
...
src/server.sh
View file @
03f39e3d
...
...
@@ -86,12 +86,21 @@ done
r[uri]
=
$(
realpath
${
cfg
[root]
}
$(
echo
${
r
[url]
}
|
sed
-E
's/\?(.*)$//'
))
[[
-d
"
${
r
[uri]
}
/"
]]
&&
pwd
=
"
${
r
[uri]
}
"
||
pwd
=
$(
dirname
"
${
r
[uri]
}
"
)
# shitty logging
echo
"-------------"
>>
log
echo
$(
date
)
>>
log
echo
"URL:
${
r
[url]
}
, GET_data:
${
get_data
[@]
}
, POST_data:
${
post_data
[@]
}
, POST_multipart:
${
post_multipart
[@]
}
"
>>
log
echo
${
r
[uri]
}
>
/dev/stderr
echo
"---"
>>
${
cfg
[log_misc]
}
echo
"
$(
date
)
"
>>
${
cfg
[log_misc]
}
if
[[
$(
tail
-n
1
${
cfg
[log_http]
}
)
==
$(
cat
/tmp/lasthttp
)
]]
;
then
r[ip]
=
$(
tail
-n
1
${
cfg
[log_https]
}
|
sed
-s
's/Ncat: Connection from //'
)
r[proto]
=
'http'
echo
"HTTPS IP:
${
r
[ip]
}
"
>>
${
cfg
[log_misc]
}
else
r[ip]
=
$(
tail
-n
1
${
cfg
[log_http]
}
|
sed
-s
's/Ncat: Connection from //'
)
r[proto]
=
'https'
echo
"HTTP IP:
${
r
[ip]
}
"
>>
${
cfg
[log_misc]
}
fi
echo
"URL:
${
r
[url]
}
, GET_data:
${
get_data
[@]
}
, POST_data:
${
post_data
[@]
}
, POST_multipart:
${
post_multipart
[@]
}
"
>>
${
cfg
[log_misc]
}
tail
-n
1
${
cfg
[log_http]
}
>
/tmp/lasthttp
if
[[
${
r
[status]
}
!=
101
]]
;
then
if
[[
-a
${
r
[uri]
}
&&
!
-r
${
r
[uri]
}
]]
;
then
...
...
@@ -113,7 +122,7 @@ if [[ ${r[status]} != 101 ]]; then
fi
if
[[
${
cfg
[auth_required]
}
==
true
&&
${
r
[authorized]
}
!=
true
]]
;
then
echo
"Auth failed."
>>
log
echo
"Auth failed."
>>
${
cfg
[log_misc]
}
r[status]
=
401
fi
...
...
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