Skip to content

Commit

Permalink
Merge pull request #34 from JaiMaaSheeravali/tut-levels
Browse files Browse the repository at this point in the history
added rest tutorial levels
  • Loading branch information
guptaprakhariitr authored May 13, 2021
2 parents 45a8b57 + d45220c commit d9b5a43
Show file tree
Hide file tree
Showing 30 changed files with 147 additions and 31 deletions.
19 changes: 11 additions & 8 deletions src/levels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,11 @@ const char *passwd_list[] = {
"j7uvv2CwUFSujANxHnM2dM4L",
"wdJPxNNK66cUGra6JJjbCLRe",
"8X8jevLsYwWpZkhvDHXUWu5Q",
"fcyHejqsN4LUgqVD9SACZLzh",
"Y99Ch3hbZy8QhDm639BCxayF",
"Q9n59xHrrTmyRcWc6Ag8m8d9",
"JtfU4VftpqH3wbB6cVdjdLqr",
"NZAbCFvQuSrPmDgrQHRCj2GZ"};
"713ef6fc74479b3881d7fdb9b696a170173f5b6c"};

string curr_pass;
int curr_level = 1;
bool unlocked[10];
bool unlocked[6];

void print_instructions(string p)
{
Expand Down Expand Up @@ -49,9 +45,16 @@ bool check_password(int level)
{
cout << "Success!!\n";
unlocked[level] = 1;
curr_level++;
if (level == 6)
cout << "All levels completed!\n";
else
curr_level++;

return 1;
}
else
{
cout << "wrong password!!\n";
return 1;
return 0;
}
}
59 changes: 36 additions & 23 deletions src/tutorial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ int create_tutorial_folder()
home = strdup(pw->pw_dir);
home_dir = home;
// roosh_launch("rm -rf " + home_dir + "/tutorial");
roosh_launch("cp -r tutorial " + home_dir);
roosh_launch("cp -r -u tutorial " + home_dir);
return 0;
}

int roosh_exec_tutorial(char **args, int num_args)
{
//number of arguments can be =>
// 1 i.e. tutorial
// 3 i.e. tutorial level <1-10>
// 4 i.e. tutorial level <1-10> password
// 3 i.e. tutorial level <1-6>
// 4 i.e. tutorial level <1-6> password

//tutorial cmd
if (num_args == 1)
Expand All @@ -62,19 +62,31 @@ int roosh_exec_tutorial(char **args, int num_args)
ss << args[2];
ss >> level;

//level must be b/w 1-10
if (level > 0 && level <= 10 && (strlen(args[2]) == level / 10 + 1))
//level must be b/w 1-6
if (level > 0 && level <= 6 && (strlen(args[2]) == level / 10 + 1))
{

if (num_args == 3)
{
//display corresponding instructins
string path = (home_dir + "/tutorial/lvl_instrns/level" + args[2] + ".txt");
print_instructions(path);

//navigate to corresponding directory
path = (home_dir + "/tutorial/tutorial_levels/level" + args[2]);
chdir(path.c_str());
if (level == 1 || unlocked[level - 1])
{
//display corresponding instructins
string path = (home_dir + "/tutorial/lvl_instrns/level" + args[2] + ".txt");
print_instructions(path);

//navigate to corresponding directory
path = (home_dir + "/tutorial/tutorial_levels/level" + args[2]);
chdir(path.c_str());
if (level == 4)
{

roosh_launch("chmod 000 " + home_dir + "/tutorial/tutorial_levels/level4/open_me");
}
}
else
{
print_no_access_to_level();
}
}

else
Expand All @@ -88,6 +100,7 @@ int roosh_exec_tutorial(char **args, int num_args)
else if (unlocked[level - 1])
{
check_password(level);

return 1;
}

Expand All @@ -101,8 +114,8 @@ int roosh_exec_tutorial(char **args, int num_args)

else
{
//display error if level is not an integer bw 1 nd 10
cerr << "Please enter a level between 1 to 10.\n";
//display error if level is not an integer bw 1 nd 6
cerr << "Please enter a level between 1 to 6.\n";
return 1;
}
}
Expand All @@ -114,11 +127,10 @@ int roosh_exec_tutorial(char **args, int num_args)
}
}


bool write_tutorial(string filepath)
{
string line;
filepath = home_dir+"/tutorial/tutorial_cmd/"+filepath;
filepath = home_dir + "/tutorial/tutorial_cmd/" + filepath;

ifstream myfile(filepath);

Expand Down Expand Up @@ -164,8 +176,9 @@ bool write_tutorial(string filepath)
getline(cin, user_choice);

cout << endl;

if(user_choice == "q"){

if (user_choice == "q")
{
myfile.close();
return true;
}
Expand All @@ -175,7 +188,7 @@ bool write_tutorial(string filepath)

else
cout << "Unable to open file";

return false;
}

Expand All @@ -201,24 +214,24 @@ int roosh_tutorial()
string user_choice;
getline(cin, user_choice);

if(user_choice == "q")
if (user_choice == "q")
return 1;

cout << endl;
cout << endl;

cout << "\n"
<< BLUE << " "
<< "Basic linux commands" << endl;
cout << RESET << endl;
exit_tut = write_tutorial("basiccmdlist.txt");

if(exit_tut)
if (exit_tut)
return 1;

cout << BLUE << " "
<< "Git linux commands" << endl;
cout << RESET << endl;
exit_tut = write_tutorial("gitcmdlist.txt");

return 1;
}
Empty file removed tutorial/lvl_instrns/level10.txt
Empty file.
4 changes: 4 additions & 0 deletions tutorial/lvl_instrns/level3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Commands you may need to solve the level-
ls cd cat grep

Hint: The password is just next to the word "gerrymandering" in any of the three files.
4 changes: 4 additions & 0 deletions tutorial/lvl_instrns/level4.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Commands you may need to solve the level-
ls cd chmod cat

Hint: The password is stored in a file named 'open_me'.
4 changes: 4 additions & 0 deletions tutorial/lvl_instrns/level5.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Commands you may need to solve the level-
ls cd find cat grep

Hint: The password is stored in a file named 'readme'.
6 changes: 6 additions & 0 deletions tutorial/lvl_instrns/level6.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Commands you may need to solve the level-
git commands like clone, log ..

Checkout our git repository => https://github.com/JaiMaaSheeravali/Roosh.git

The commit hash for the first commit by the author "Prakahar Gupta" in this repository is the password ..
Empty file removed tutorial/lvl_instrns/level7.txt
Empty file.
Empty file removed tutorial/lvl_instrns/level8.txt
Empty file.
Empty file removed tutorial/lvl_instrns/level9.txt
Empty file.
1 change: 1 addition & 0 deletions tutorial/tutorial_levels/level3/file1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Far curiosity incommode now led smallness allowance. Favour bed assure son things yet. She consisted consulted elsewhere happiness disposing household any old the. Widow downs you new shade drift hopes small. So otherwise commanded sweetness we improving. Instantly by daughters resembled unwilling principle so middleton. Fail most room even gone her end like. Comparison dissimilar unpleasant six compliment two unpleasing any add. Ashamed my company thought wishing colonel it prevent he in. Pretended residence are something far engrossed old off.Quick six blind smart out burst. Perfectly on furniture dejection determine my depending an to. Add short water court fat. Her bachelor honoured perceive securing but desirous ham required. Questions deficient acuteness to engrossed as. Entirely led ten humoured greatest and yourself. Besides ye country on observe. She continue appetite endeavor she judgment interest the met. For she surrounded motionless fat resolution may. Moments its musical age explain. But extremity now education concluded earnestly her continual. Oh furniture acuteness suspected continual ye something frankness. Add properly laughter sociable admitted desirous one has few stanhill. Opinion regular in perhaps another enjoyed no engaged he at. It conveying he continual ye suspected as necessary. Separate met packages shy for kindness. Abilities or he perfectly pretended so strangers be exquisite. Oh to another chamber pleased imagine do in. Went me rank at last loud shot an draw. Excellent so to no sincerity smallness. Removal request delight if on he we. Unaffected in we by apartments astonished to decisively themselves. Offended ten old consider speaking. Its had resolving otherwise she contented therefore. Afford relied warmth out sir hearts sister use garden. Men day warmth formed admire former simple. Humanity declared vicinity continue supplied no an. He hastened am no property exercise of. Dissimilar comparison no terminated devonshire no literature on. Say most yet head room such just easy. Attended no do thoughts me on dissuade scarcely. Own are pretty spring suffer old denote his. By proposal speedily mr striking am. But attention questions applauded how happiness. To travelling occasional at oh sympathize prosperous. His merit end means widow songs linen known. Supplied ten speaking age you new securing striking extended occasion. Sang put paid away joy into six her. Material confined likewise it humanity raillery an unpacked as he. Three chief merit no if. Now how her edward engage not horses. Oh resolution he dissimilar precaution to comparison an. Matters engaged between he of pursuit manners we moments. Merit gay end sight front. Manor equal it on again ye folly by match. In so melancholy as an sentiments simplicity connection. Far supply depart branch agreed old get our. Had denoting properly jointure you occasion directly raillery. In said to of poor full be post face snug. Introduced imprudence see say unpleasing devonshire acceptance son. Exeter longer wisdom gay nor design age. Am weather to entered norland no in showing service. Nor repeated speaking shy appetite. Excited it hastily an pasture it observe. Snug hand how dare here too. Stronger unpacked felicity to of mistaken. Fanny at wrong table ye in. Be on easily cannot innate in lasted months on. Differed and and felicity steepest mrs age outweigh. Opinions learning likewise daughter now age outweigh. Raptures stanhill my greatest mistaken or exercise he on although. Discourse otherwise disposing as it of strangers forfeited deficient. Was justice improve age article between. No projection as up preference reasonably delightful celebrated. Preserved and abilities assurance tolerably breakfast use saw. And painted letters forming far village elderly compact. Her rest west each spot his and you knew. Estate gay wooded depart six far her. Of we be have it lose gate bred. Do separate removing or expenses in. Had covered but evident chapter matters anxious. By spite about do of do allow blush. Additions in conveying or collected objection in. Suffer few desire wonder her object hardly nearer. Abroad no chatty others my silent an. Fat way appear denote who wholly narrow gay settle. Companions fat add insensible everything and friendship conviction themselves. Theirs months ten had add narrow own. Fat son how smiling mrs natural expense anxious friends. Boy scale enjoy ask abode fanny being son. As material in learning subjects so improved feelings. Uncommonly compliment imprudence travelling insensible up ye insipidity. To up painted delight winding as brandon. Gay regret eat looked warmth easily far should now. Prospect at me wandered on extended wondered thoughts appetite to. Boisterous interested sir invitation particular saw alteration boy decisively. An do on frankness so cordially immediate recommend contained. Imprudence insensible be literature unsatiable do. Of or imprudence solicitude affronting in mr possession. Compass journey he request on suppose limited of or. She margaret law thoughts proposal formerly. Speaking ladyship yet scarcely and mistaken end exertion dwelling. All decisively dispatched instrument particular way one devonshire. Applauded she sportsman explained for out objection.Cultivated who resolution connection motionless did occasional. Journey promise if it colonel. Can all mirth abode nor hills added. Them men does for body pure. Far end not horses remain sister. Mr parish is to he answer roused piqued afford sussex. It abode words began enjoy years no do no. Tried spoil as heart visit blush or. Boy possible blessing sensible set but margaret interest. Off tears are day blind smile alone had. He do subjects prepared bachelor juvenile ye oh. He feelings removing informed he as ignorant we prepared. Evening do forming observe spirits is in. Country hearted be of justice sending. On so they as with room cold ye. Be call four my went mean. Celebrated if remarkably especially an. Going eat set she books found met aware.Of friendship on inhabiting diminution discovered as. Did friendly eat breeding building few nor. Object he barton no effect played valley afford. Period so to oppose we little seeing or branch. Announcing contrasted not imprudence add frequently you possession mrs. Period saw his houses square and misery. Hour had held lain give yet. Folly was these three and songs arose whose. Of in vicinity contempt together in possible branched. Assured company hastily looking garrets in oh. Most have love my gone to this so. Discovered interested prosperous the our affronting insipidity day. Missed lovers way one vanity wishes nay but. Use shy seemed within twenty wished old few regret passed. Absolute one hastened mrs any sensible. Lose john poor same it case do year we. Full how way even the sigh. Extremely nor furniture fat questions now provision incommode preserved. Our side fail find like now. . Discovered travelling for
Loading

0 comments on commit d9b5a43

Please sign in to comment.