The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
SSH Password-less login fails on password expiry. Renjesh SUN Solaris 2 04-24-2009 01:53 AM
Solaris 8 - Asks for current root password when trying to change root password. tferrazz SUN Solaris 8 04-07-2009 03:28 PM
how to change root password using shell script with standard password kurva Shell Programming and Scripting 2 02-25-2009 02:35 AM
password verification verify password of a user for only first 8 characters amitpansuria UNIX for Advanced & Expert Users 12 10-23-2008 11:03 AM
Change password by pushing encrypted password to systems benq70 UNIX for Dummies Questions & Answers 1 09-02-2005 10:08 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-19-2009
tavibaroi tavibaroi is offline
Registered User
  
 

Join Date: Oct 2009
Posts: 5
oh i see you didn`t understand me.
I will show you like this.
This is a bash script wich perfom uname -a with password protected so if you know the password you get the uname -a else exit.danremo`s script thx.
--
pass=espana
echo -n "Type password:";
read pass2;
if [ ${pass}. != ${pass2}. ];
then
echo "Wrong password, bye";
else
echo OK password acepted !;
uname -a
fi
--
now, what i am searching about is the same thing only writed in c++ wich i have very little knowledge about.
thank you !
  #2 (permalink)  
Old 10-19-2009
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,763
Code:
/* mypass.c */
#include <stdio.h>
#include <unistd.h>
#include <string.h>

int main(int argc, char **argv)
{
    char *pswd="espana";
    char *result=getpass("Enter password");   
    if(strcmp(pswd, result)==0 )
       return 0;
    return 1;
    
}
Are you sure this is not homework? This makes no sense - anybody who is at the commandline prompt can type uname -a and get a response.

Code:
  ./mypass
  if [ $? -eq 0 ] ; then
      uname -a
  else
      echo 'bad password'
  fi
  #3 (permalink)  
Old 10-19-2009
tavibaroi tavibaroi is offline
Registered User
  
 

Join Date: Oct 2009
Posts: 5
yes this is what i looking for !
thanks man ! very very nice !

---------- Post updated at 01:45 PM ---------- Previous update was at 01:43 PM ----------

i am wondering if there is any chance to hide the password ? when i strings the file shows :
/lib/ld-linux.so.2
_Jv_RegisterClasses
__gmon_start__
libc.so.6
getpass
system
strcmp
_IO_stdin_used
__libc_start_main
GLIBC_2.0
PTRh
espana <--
Enter password

dont know , some md5sum maybe ?
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:57 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0