How I created a bot that marked my attendance for the whole semester

Shubham Arya
4 min readJan 19, 2021

What is this article about

Hello readers, today I’m gonna break down how my laziness pushed me to create a bot, and learn some awesome new stuff. I named it ImSleepy because, well I was sleepy. But I created this project just for educational purposes and I don’t encourage skipping lectures.

TL;DR

I created a super awesome bot that attended my lectures to mark my attendance. Here it is Im-Sleepy. Check it out, contribute to it if you want. It’s of no use to me now, college over :(

Why I made the bot

It was a normal boring day during the lockdown and I had to login to my university’s website to attend lectures. Believe me, it is a tiring process to get out of bed, then logon to my laptop and then the website and then attend a lecture. Blehh… too much work, so I thought, how can I automate it. Then I asked my best friend google, “how to be lazy”, and he provided me with a lot of stackoverflow pages, then I popped up vim ( yes I code in vim, am I cool now ?) and started coding.

What I made exactly

A python bot that:
1. Starts up at a specific time of the day (according to my time table).

2. Logs in to my college website (with the creds I provide in the config file).

3. Choose the lecture which is scheduled in my time table.

4. Visit it and open up the lecture.

5. Take a screenshot (for proof ofcourse).

6. Run until the lecture ends.

7. Shuts down. (and much more)

It’s features:

  1. Can run in the foreground like a normal browser, so you can attend classes like you used to.
  2. Can run in the background (without even popping up a browser..!!!).
  3. Can send messages in the chat (like “Present Ma’am” xD).
  4. Can take as many screenshots of the lecture as you want.
  5. Can be run manually ( choose each option ) or automatically.

What technologies I used ( The Ingredients )

  • Python(3): as the base language.
  • Selenium framework: For popping up a browser and automate human actions (like logging in, typing etc.).
  • Beautiful Soup: For scraping html and displaying it on the console.
  • Bash: To create cronjobs for the script to run at a specific time.
  • Brain: To do the obvious stuff.
  • Coffee: To help “brain” do the obvious stuff.

What was my methodology ( The Recipie)

My main goal was to create a script that simply logged on to the website for me, but as I started to discover the things I could do with “The ingredients”, and the possibilites of my laziness to expand became immense.

So breaking it down one by one:

  • Open up a browser: From googling about “how to run browser in terminal” to actually finding something useful, it took me some time. Then I discovered selenium. This framework is used to automate web application tests. It opens up a browser and then executes the given actions ( like clicking, etc.). Digging deep into this, I found that the browser can be opened in “headless” mode (jackpot..!!). Now I can attend my classes, without even opening up a browser (my laptop back then was old and laggy so this was a huge plus point). This was also an advantage for me as I can simply run the program on a VPS and not worry about my internet charges too (my internet was sh**ty as well).
  • Logging in: Great, now we have our browser open. So we can visit our college website, and just program our way to laziness, easy peasy ? Nope, not that easy. I had to study the web application carefully, tracking api calls, how does it determine wether the attendance has been marked or not, how does it handles user input, how does it lists courses and a lot more. This took the most time, but it was worth it. I easily understood how the application works, and replicating the user interaction became really easy.
  • Attending classes and taking screenshots: Taking screenshots was easy, there is a built in function that comes with selenium. For using the bot I created three modes:
    1. Browser mode-Open the browser, visit the college website, login and let the user do what he wants.
    2. Headless mode- Run the browser in invisible(headless) mode, display courses and choices on the terminal, let the user choose what he wants to do.
    3. LazyAf mode- Input the time table of the user, set scheduled crontabs, attend classes automatically each day every day. I used this mode on a VPS, so it was a one time setup and then no headache for the rest of the semester, it kept attending all my classes ( ofcourse I did not do this, I am a very good student and attended classes regularly (: )
  • Closing the browser: ```sys.exit()``` lol.
  • How can my script be defeated: Just by adding a captcha on the login page. ( But I will find a way to bypass that too hehe)

Conclusion and Disclaimer..!!!

My main motive to create this was 2 things, I wanted to kill my boredom, I wanted to learn something new ( I always want to learn something new ). I never intended to anything wrong, and I released this project just for educational purposes, learn from it and use it wisely.

Thankyou :D

--

--

Shubham Arya

Cyber Security Enthusiast | Computer Science Engineering Student | Bug Bounty Newbie | CTF Player