Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
4
42 Resa
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Divers
42 Resa
Commits
e342e98a
Commit
e342e98a
authored
3 years ago
by
Yann
Browse files
Options
Downloads
Patches
Plain Diff
init
parents
Branches
master
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
.gitignore
+1
-0
1 addition, 0 deletions
.gitignore
README.md
+5
-0
5 additions, 0 deletions
README.md
login.py
+50
-0
50 additions, 0 deletions
login.py
requirements.txt
+1
-0
1 addition, 0 deletions
requirements.txt
with
57 additions
and
0 deletions
.gitignore
0 → 100644
+
1
−
0
View file @
e342e98a
**.swp
This diff is collapsed.
Click to expand it.
README.md
0 → 100644
+
5
−
0
View file @
e342e98a
# 42 reservation bot
! WIP !
Tool to automatically book a correction slot
This diff is collapsed.
Click to expand it.
login.py
0 → 100755
+
50
−
0
View file @
e342e98a
#! /usr/bin/env python3
import
requests
,
sys
,
getpass
url
=
'
https://signin.intra.42.fr/users/sign_in
'
session
=
requests
.
session
()
def
get_csrf
(
r
):
csrf
=
{
'
payload
'
:
dict
(),
'
param
'
:
False
,
'
token
'
:
False
}
for
line
in
r
.
text
.
split
(
'
\n
'
):
if
'
csrf
'
in
line
:
if
'
csrf-param
'
in
line
:
csrf
[
'
param
'
]
=
line
.
split
(
'"'
)[
3
]
elif
'
csrf-token
'
in
line
:
csrf
[
'
token
'
]
=
line
.
split
(
'"'
)[
3
]
if
not
csrf
[
'
param
'
]
or
not
csrf
[
'
token
'
]:
return
False
csrf
[
'
payload
'
]
=
{
csrf
[
'
param
'
]:
csrf
[
'
token
'
]}
return
(
csrf
[
'
payload
'
])
payload
=
get_csrf
(
session
.
get
(
url
))
if
not
payload
:
print
(
'
Error: Could not get csrf values
'
,
file
=
sys
.
stderr
)
exit
(
1
)
payload
[
'
user[login]
'
]
=
input
(
'
42 login:
'
)
payload
[
'
user[password]
'
]
=
getpass
.
getpass
()
r
=
session
.
post
(
url
,
data
=
payload
)
if
'
signin
'
in
r
.
url
:
inside_div
=
False
for
line
in
r
.
text
.
split
(
'
\n
'
):
if
inside_div
:
print
(
line
.
split
(
'
>
'
)[
1
].
split
(
'
<
'
)[
0
],
file
=
sys
.
stderr
)
break
inside_div
=
(
'
notifications-flash-top-bar
'
in
line
)
exit
(
1
)
print
(
'
Cookie `_intra_42_session_production`:
'
,
session
.
cookies
.
get
(
'
_intra_42_session_production
'
))
This diff is collapsed.
Click to expand it.
requirements.txt
0 → 100644
+
1
−
0
View file @
e342e98a
requests
This diff is collapsed.
Click to expand it.
Preview
0%
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