LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 10-16-2015, 12:25 AM   #1
davidgeek
LQ Newbie
 
Registered: Oct 2015
Posts: 2

Rep: Reputation: Disabled
New to command script


Hi all, I am a newbie to command scripting and trying to perfect it. I was reading an introduction to computer security book that I found in the library and was trying out the tutorial. However being a noob, I am stuck with two of the questions and would like to humbly seek help from the community.

Q1.Write an attack script or a program to list the content of the directory /home/alice/Private/ where Alice is a super user. The attack must work when executed by user charlie (non super user). If your program/script works correctly, it should show something that looks like the output of a ‘ls –l’ command,

Below is my code:

#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
int main(void)
{
system("cd ./home/alice/Public; ./mysecret ';ls -l /home/alice/Private;'");

}


Q2. Write a script/program to display the application password and the secret of the admin user.

Solution: This question I really do not even know how to start

Just F.Y.I, this is not some homework os school assignment. I am too old for that. It's just something I want to pick up and learn and hope I can make new friend from the linux community. Thanks
 
Old 10-16-2015, 01:53 AM   #2
jdkaye
LQ Guru
 
Registered: Dec 2008
Location: Westgate-on-Sea, Kent, UK
Distribution: Debian Testing Amd64
Posts: 5,465

Rep: Reputation: Disabled
Do you really think it's a good idea to publish the code for attack scripts? I don't know the answer to your queries but if I did, I would really not care to place them on a publicly viewable forum.
jdk
 
1 members found this post helpful.
Old 10-16-2015, 03:35 AM   #3
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by davidgeek View Post
I am a newbie to command scripting
What you are writing is not a command script, but a C program.

Quote:
Code:
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
int main(void)
{   
     system("cd ./home/alice/Public; ./mysecret ';ls -l /home/alice/Private;'");

}
This won't work, since there is no program named "cd".
You can however use the chdir() system call prior to calling system():
Code:
    if ( chdir("/home/alice/Public")<0 )
        perror("Couldn't cd to /home/alice/Public");
The problem is that Charlie is unlikely to have the right permissions to cd to Alice's home directory.
Also, I don't know what "mysecret" is supposed to accomplish and I find the parameter to "mysecret" very strange - why does it start with a semicolon?

Quote:
Q2. Write a script/program to display the application password and the secret of the admin user.

Solution: This question I really do not even know how to start
Neither do I, as I am utterly lacking context; what are the application and the secret mentioned in the question?
 
Old 10-18-2015, 01:45 PM   #4
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
[Moderator note: I've moved the question to Linux-Security. This forum is better for that kind of questions]
 
Old 10-18-2015, 11:17 PM   #5
davidgeek
LQ Newbie
 
Registered: Oct 2015
Posts: 2

Original Poster
Rep: Reputation: Disabled
Hi Jdkaye, it's for practice on my understanding of the various access control and how to access them.
Hi bernadbauch, thanks a million for your help. Yes you are right, it's a C program and not a command script. The first question is to write a C program to access the private directories of the privileged user from the directory of a normal user with no privilege access. mySecret is the executable that is generated by a program stored in the private directory of the privilege user.

As for the second question, I am suppose to write a script to access the application password that is stored in the private directory of the privilege user. Thanks for your help once again.

Sure thanks Mara. I am lacking practice.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Any Linux command output to delimited format. Script should work for any command. torrelm@hotmail.com Linux - Newbie 9 09-04-2014 08:54 AM
Bash script - command works directly in command line but not in script raoulcousins Linux - Newbie 6 08-21-2013 07:43 PM
[SOLVED] run ps|grep command by script/command line ... ERROR: Unsupported option (BSD syntax) masuch Programming 4 05-23-2012 04:13 AM
Command/Script required to send an email alert in case command will not respond rajaniyer123 Linux - General 1 05-19-2012 01:12 PM
busybox command works, same command within script says permission denied jeroenv Linux - Newbie 2 01-17-2009 02:58 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 11:13 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration