Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 95 additions & 0 deletions Pradyumn_V/otw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
## Level 0

### pswd - bandit0

used ssh to login to the server for overthewire where bandit is played

## Level 1

### pswd - ZjLjTmM6FvvyRnrb2rfNWOZOTa6ip5If

used ls to find readme file and used **cat** to read the contents

## Level 2

### pswd - 263JGJPfgU6LtdEvgfWU1XP5yac29mFx

used ls to find a file named '-' used ./- to specify the entire directory because passing only cat - can cause problems since - is commonly used to pass arguements to the function

## Level 3

### pswd - MNk8KNH3Usiio41PRUEoDFPqfxLPlSmx

used quotations to specify the filename when passed as an arguement in cat

## Level 4

### pswd - 2WmrDFRmJIq3IPxneAaMGhap0pFhF3NJ

used **ls -a** to show all files including hidden ones then read the file using **cat ./...Hidden-From-You**

## Level 5

### pswd - 4oQYVPkxZOOEOO5pTW81FB8j8lxXGUQw

used file ./* to find the type of text in all files and read the file07 using cat since it contained ASCII characters

## Level 6

### pswd - HWasnPhtq9AVKe0dmk45nxy20cvUa6EG

executed **file */* | grep "ASCII text" | du -b -a | grep 1033** to extract all ascii text files of size 1033 since only 1 result showed, read that using cat and got the password

## Level 7

### pswd - morbNTDkSW6jIlUc0ymOdMaLnOlFVAaj

used **find / -user bandit7 -group bandit6 -size 33c 2>/dev/null** we add the last part to hide all permission denied error messages

## Level 8

### pswd - dfwvzFQi4mU0wfNbFOe9RoWskMLg7eEc

**cat data.txt | grep millionth** returned the complete line containing millionth including the password

## Level 9

### pswd - 4CKMh1JI91bUIZZPXDqGanal4xvAg0JM

**sort data.txt | uniq -u** sort will sort the file allowing uniq to filter out repeating lines using the -u tag and return the only line appearing once

## Level 10

### pswd - FGUW5ilLVJrxX9kMYMmlN4MgbpfMiqey

**cat data.txt | strings | grep ==** strings will return all human readable lines and grep filters them

## Level 11

### pswd - dtR173fZKb0RRsDFSGsg2RWnpNVj3qRr

**cat data.txt | base64 -d** decrypts the encoded text and returns password

## Level 12

### pswd - 7x16WNeHIi5YkIhWsfFIqoognUTyj9Q4

**cat data.txt | tr 'A-Za-z' 'N-ZA-Mn-za-m'** translate command is used to execute rotation by 13 on the character skipping numerical values

## Level 13

### pswd - FO5dwFsc0cbaIiH0h8J2eUks2vdTDwAn

we know that first we extract the hexadecimal contents then on reading it using **xxd** we see gzip compressed files start with 1f 8b as their first few bytes hence we decrypt then we see 425a which is bzip2 we repeat this process and encounter .bin files indicating archive extracted using **tar -xf**

## Level 14

### pswd - MU4VWeTyJk8ROof1qqmcBPaLh7lDCPvS

first we find the location of the ssh key file using ls then we download it by logging out and accessing the server from our computer using scp (secure copy protocol) for transferring files between hosts over a network then we reduce permissions using chmod 700 and finally login using the sshkey.private with -i tag with ssh

## Level 15

### pswd - 8xCjnmgoKbGLhHFAZlGE5Tmu4M2tKJQo

submitted level 14 password using **nc localhost 30000** and entering the password when prompted
7 changes: 7 additions & 0 deletions Task2/pradyumn_v/Content.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include "Content.h"

Content::Content(string name, string type, int rated){
title = name;
genre = type;
rating = (rated<=5)?rated:0;
}
13 changes: 13 additions & 0 deletions Task2/pradyumn_v/Content.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#pragma once
#include<iostream>
using namespace std;

class Content{
public:
string title;
string genre;
int rating;
bool is_rented=false;
bool is_purchased=false;
Content(string name, string type, int rated);
};
6 changes: 6 additions & 0 deletions Task2/pradyumn_v/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM gcc:latest
WORKDIR /usr/src/app
COPY . .
RUN g++ *.cpp -o media_rental_system
VOLUME ["/app/user", "/app/admin", "/app/catalogues"]
CMD ["./media_rental_system"]
145 changes: 145 additions & 0 deletions Task2/pradyumn_v/admin.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
#include "admin.h"

void Admin::save(const string& filename) {
ofstream out(filename);
if (!out) {
cerr << "Could not open file for writing.\n";
return;
}
out << username << '\n' << password << '\n';

out.close();
}

void Admin::load(const string& filename) {
ifstream in(filename);
if (!in) {
cerr << "Could not open file for reading.\n";
return;
}
getline(in, username);
getline(in, password);
in.close();
}


void Admin::save_catalogues(const string& filename, movie_entry* movie_cat, tv_show_entry* show_cat){
ofstream out(filename);
if (!out) {
cerr << "Error opening file for writing: " << filename << endl;
return;
}

movie_entry* m = movie_cat;
while (m) {
Movie* movie = m->data;
out << "MOVIE " << movie->title << " "
<< movie->genre << " " << movie->rating << " "
<< movie->duration << " " << movie->rent_cost << " "
<< movie->purchase_cost << "\n";
m = m->next;
}

tv_show_entry* s = show_cat;
while (s) {
Show* show = s->data;
out << "SHOW " << show->title << " "
<< show->genre << " " << show->rating << " "
<< show->seasons << " " << show->ep_per_season << " "
<< show->rent_cost << " " << show->purchase_cost << "\n";
s = s->next;
}

out.close();
}




movie_entry* Admin::add_movie(string title, string type, int rated, int time, int rent, int purchase, movie_entry* head){
movie_entry* entry = new movie_entry;
entry->data = new Movie(title, type, rated, time, rent, purchase);
entry->next=nullptr;
bool added = false;

if(!head){
return entry;
}

movie_entry* curr = head;
while(curr->next){
if(curr->data->genre==entry->data->genre){
entry->next=curr->next;
curr->next = entry;
added = true;
break;
}
curr = curr->next;
}
if(!added){
curr->next = entry;
}
return head;
}

movie_entry* Admin::remove_movie(string name, movie_entry* head){
movie_entry* curr = head;
movie_entry* prev = nullptr;
if(curr->data->title==name){
head = curr->next;
return head;
}
while(curr->data->title!=name){
prev = curr;
curr = curr->next;
if(curr==nullptr){
return head;
}
}
prev->next = curr->next;
return head;
}

tv_show_entry* Admin::add_show(string title, string type, int rated, int season, int ep_per_seasons, int time, int rent, int purchase, tv_show_entry* head){
tv_show_entry* entry = new tv_show_entry;
entry->data = new Show(title, type, rated, season, ep_per_seasons, rent, purchase);
entry->next=nullptr;
bool added = false;

if(!head){
return entry;
}

tv_show_entry* curr = head;
while(curr->next){
if(curr->data->genre==entry->data->genre){
entry->next=curr->next;
curr->next = entry;
added = true;
break;
}
curr = curr->next;
}
if(!added){
curr->next = entry;
}
return head;
}

tv_show_entry* Admin::remove_show(string name, tv_show_entry* head){
tv_show_entry* curr = head;
tv_show_entry* prev = nullptr;
if(curr->data->title==name){
head = curr->next;
return head;
}
while(curr->data->title!=name){
prev = curr;
curr = curr->next;
if(curr==nullptr){
return head;
}
}
prev->next = curr->next;
return head;
}
19 changes: 19 additions & 0 deletions Task2/pradyumn_v/admin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#pragma once
#include<iostream>
#include "show_entry.h"
#include "movie_entry.h"
#include<fstream>
using namespace std;

class Admin{
public:
string username;
string password;
void save(const string& filename);
void load(const string& filename);
void save_catalogues(const string& filename, movie_entry* movie_cat, tv_show_entry* show_cat);
movie_entry* add_movie(string title, string type, int rated, int time, int rent, int purchase, movie_entry* head);
movie_entry* remove_movie(string name, movie_entry* head);
tv_show_entry* add_show(string title, string type, int rated, int season, int ep_per_seasons, int time, int rent, int purchase, tv_show_entry* head);
tv_show_entry* remove_show(string name, tv_show_entry* head);
};
2 changes: 2 additions & 0 deletions Task2/pradyumn_v/admin/admin1.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
admin1
34567
3 changes: 3 additions & 0 deletions Task2/pradyumn_v/catalogues/data.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
MOVIE MeBeforeYou Romantic 3 100 120 140
SHOW TBBT SitCom 4 8 24 300 350
SHOW HIMYM SitCom 2 11 13 400 3000
Loading