Skip to content

Instantly share code, notes, and snippets.

@MrCirdo
Created February 17, 2021 15:48
Show Gist options
  • Save MrCirdo/977ec747a72b2dda347ba0c60a0678cf to your computer and use it in GitHub Desktop.
Save MrCirdo/977ec747a72b2dda347ba0c60a0678cf to your computer and use it in GitHub Desktop.
This script bypass 80% of ANSSI (exclude video)
#!/usr/bin/env python3
"""
This code is based on https://blog.moulard.org/anssi-mooc-on-hacking/
The operation is very similar.
However it does not work with video :(
"""
from selenium import webdriver
import time
user = "Username"
passw = "Password"
driver = webdriver.Chrome(executable_path="./chromedriver")
def connect():
driver.get("https://secnumacademie.gouv.fr/")
driver.find_elements_by_id("btn_access_insc")[0].click()
driver.find_elements_by_id("login")[0].send_keys(user)
driver.find_elements_by_id("password")[0].send_keys(passw)
xpath = '/html/body/div[2]/div/div[2]/div/div[1]/div[1]/div[2]/a[1]'
driver.find_elements_by_xpath(xpath)[0].click()
def pass_diapo():
driver.switch_to.default_content()
driver.switch_to.frame("DEFAUT")
driver.switch_to.frame("contents")
iframe_id = driver.find_elements_by_id("content")[0].find_elements_by_tag_name("iframe")[0].get_attribute("id")
driver.switch_to.frame(iframe_id)
driver.execute_script("for(var i = 0; i < 15; i++) {document.querySelector('#Stage_menu_inferieur_bouton_suivant_hit').click()}")
def do_questionaire():
driver.switch_to.default_content()
driver.switch_to.frame("DEFAUT")
driver.switch_to.frame("contents")
iframe_id = driver.find_elements_by_id("content")[0].find_elements_by_tag_name("iframe")[0].get_attribute("id")
driver.switch_to.frame(iframe_id)
for _ in range(10):
time.sleep(0.5)
driver.execute_script("$this.hits.forEach(function(a){a.reponse = \"\"})")
driver.execute_script("document.querySelector('#Stage_ecran_1_bouton_valider_hit').click()")
driver.execute_script("document.querySelector('#Stage_menu_inferieur_bouton_suivant_hit').click()")
def main():
connect()
while True:
response = input("Diapo [D] (default), questionaire [Q], exit [E] : ")
if response == "E":
exit(0)
elif response == "D":
pass_diapo()
elif response == "Q":
do_questionaire()
else:
pass_diapo()
if __name__ == '__main__':
main()
@youenn-loie
Copy link

c carré

@vladimir92i
Copy link

ça marche plus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment