Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Dokos
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cylab
Dokos
Commits
e5f9f2d2
Commit
e5f9f2d2
authored
2 years ago
by
Thibault Debatty
Browse files
Options
Downloads
Patches
Plain Diff
validate URL and show HTTP errors
parent
a687eceb
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pyproject.tmpl
+4
-0
4 additions, 0 deletions
pyproject.tmpl
src/dokos/dokos.py
+33
-8
33 additions, 8 deletions
src/dokos/dokos.py
with
37 additions
and
8 deletions
pyproject.tmpl
+
4
−
0
View file @
e5f9f2d2
...
...
@@ -11,6 +11,10 @@ authors = [
description = "HTTP login cracker"
readme = "README.md"
requires-python = ">=3.7"
dependencies = [
'validators'
]
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
...
...
This diff is collapsed.
Click to expand it.
src/dokos/dokos.py
+
33
−
8
View file @
e5f9f2d2
...
...
@@ -8,6 +8,8 @@ import urllib.request
import
concurrent.futures
from
threading
import
Lock
import
os
import
math
import
validators
# print lock
...
...
@@ -17,6 +19,10 @@ LOCK = Lock()
ARGS
=
None
FOUND
=
[]
def
print_safe
(
string
)
:
with
LOCK
:
print
(
string
)
def
show_version
()
:
# where is this file located
dirname
=
os
.
path
.
dirname
(
__file__
)
...
...
@@ -52,14 +58,22 @@ def try_password(password) :
}
encoded_data
=
urllib
.
parse
.
urlencode
(
data
).
encode
(
'
ascii
'
)
req
=
urllib
.
request
.
Request
(
ARGS
.
url
,
encoded_data
)
with
urllib
.
request
.
urlopen
(
req
)
as
response
:
request
=
urllib
.
request
.
Request
(
ARGS
.
url
,
encoded_data
)
try
:
response
=
urllib
.
request
.
urlopen
(
request
)
page
=
response
.
read
().
decode
()
if
not
ARGS
.
failed
in
page
:
FOUND
.
append
(
password
)
except
urllib
.
error
.
HTTPError
as
e
:
print_safe
(
"
Error:
"
+
repr
(
e
))
except
urllib
.
error
.
URLError
as
e
:
print_safe
(
"
Error:
"
+
repr
(
e
))
def
try_passwords
(
passwords
):
'''
Try a list of passwords
...
...
@@ -67,8 +81,7 @@ def try_passwords(passwords):
for
password
in
passwords
:
password
=
password
.
strip
()
with
LOCK
:
print
(
"
login:
"
+
ARGS
.
login
+
"
password:
"
+
password
)
print_safe
(
"
login:
"
+
ARGS
.
login
+
"
password:
"
+
password
)
try_password
(
password
)
def
islice
(
iterable
,
*
args
):
...
...
@@ -142,10 +155,22 @@ def main():
show_header
()
parse_arguments
()
if
not
validators
.
url
(
ARGS
.
url
)
:
print
(
"
URL
"
+
ARGS
.
url
+
"
is not valid!
"
)
sys
.
exit
(
-
1
)
with
open
(
ARGS
.
passwords
,
"
r
"
)
as
passwords_file
:
passwords
=
passwords_file
.
readlines
()
print
(
'
Starting:
'
+
str
(
ARGS
.
threads
)
+
'
threads,
'
+
str
(
len
(
passwords
))
+
'
passwords
'
)
# passwords-per-thread
ppt
=
math
.
ceil
(
float
(
len
(
passwords
))
/
ARGS
.
threads
)
print
(
'
URL:
'
+
ARGS
.
url
)
print
(
'
Login:
'
+
ARGS
.
login
)
print
(
'
Trying:
'
+
str
(
len
(
passwords
))
+
'
passwords with
'
+
str
(
ARGS
.
threads
)
+
'
threads
'
+
'
[
'
+
str
(
ppt
)
+
'
passwords per thread]
'
)
print
(
''
)
# https://stackoverflow.com/a/15143994
executor
=
concurrent
.
futures
.
ThreadPoolExecutor
(
ARGS
.
threads
)
...
...
@@ -157,9 +182,9 @@ def main():
concurrent
.
futures
.
wait
(
futures
)
except
KeyboardInterrupt
:
# User interrupt the program with ctrl+c
print
(
"
Stopping threads...
"
)
executor
.
shutdown
(
wait
=
Tru
e
,
cancel_futures
=
True
)
sys
.
exit
(
-
1
)
print
_safe
(
"
Stopping threads...
"
)
executor
.
shutdown
(
wait
=
Fals
e
,
cancel_futures
=
True
)
sys
.
exit
()
print
(
"
Done!
"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment