Re: Change login and password prompt

From: Chaotic Thought (chaotic_thought_at_yahoo.com)
Date: 07/07/04


Date: 6 Jul 2004 23:44:52 -0700

pcouas@infodev.fr wrote in message news:<af5681c8.0407050118.6fff450e@posting.google.com>...
>
> Where can i change Password and Login Prompt.
> I want replace Password : by pwd:

Other posters have suggested ways to avoid answering your question and
why it's a bad idea to do what you're suggesting, but I haven't seen a
good explanation given yet as to *how* to do what you want. Since I
think the reasons for doing it or not doing it are unimportant
compared to the knowledge of how to do it, here's my take at it:

The "correct" way to change the "Password:" text to something of your
choice would be to get the source, modify it, and recompile. But in my
opinion, that takes too long, and is too complicated to explain. A
simpler and more direct approach is to do a simple binary patch.
First, make a backup copy. I did this by copying the system "login" to
my home directory:

   $ cd
   $ cp /sbin/login .

Now you need to find the string you want to change in the file and
note its byte-offset. To do this, I used grep with the -b (byte
offset) and -a (treat binary as text) options. Note that -b outputs
the byte-offset of the beginning of the line of text, so you have to
add to that number the correct number of bytes. For instance, I got
this

   $ grep -ba "Password:" login
   1198: fh:p /dev/tty?? login xx Password: Login incorrect (...)

This means that at byte 1198 is the character ' ' followed by 'f'. You
can confirm this with the dd command:

   $ dd if=login skip=1198 bs=1 count=2 2>/dev/null
    f

The 'dd' command normally outputs how many records it input/output but
I disabled that with the 2>/dev/null to make the example clearer. The
first two blocks (count=2) of the input file 'login' (if=login) each
block of which was 1 byte in length (bs=1), were output starting at
block 1198 (skip=1198).

So, looking at the output from grep, add the appropriate number of
bytes to get to the "Password:" string, and then confirm that you've
got it right

   $ dd if=login skip=1224 bs=1 count=10
   Password:

Note that I said count=10 instead of count=9. There are indeed 10
bytes there, 'Password:' is 9 bytes plus the null terminator is
another byte. How do I know that's a null terminator and not a space?
You can check by doing this:

   $ dd if=login skip=1224 bs=1 count=10 | tr '\000' 0
   Password:0

The 'tr' command I did here translated the octal code \000 (null) to
the ascii digit '0' so that it can be distinguished from whitespace on
the terminal. Okay -- now we're ready to patch that part of the file
with the string we want. It's important that you terminate your
replacement string in the same way as was in the input file. In other
words, don't end with a \n (newline), end with a \0 (null). The
command 'echo -en' will do this, so on my system I did

   $ echo -en 'pwd:\000' | tr '\000' '0'
   pwd:0$

Remember that the '0' at the end is not a real ascii zero, it is just
there to show that its a bonafide null-terminated string. Also notice
the '$' right after the '0': Unless your prompt (the '$' in my
examples) includes a newline character, the prompt will display right
after your string without a newline in between, since there was no
newline output after the "pwd:" string. Now that the string looks
correct, we apply it to the file with the 'dd' command:

   $ echo -en 'pwd:\000' | dd of=login seek=1224 bs=1 conv=notrunc

Key here is to use 'conv=notrunc' option to dd. If you don't, 'dd'
will end the file right after your replacement string, so you will get
a non-working program. The original 'login' and your modified 'login'
should be exactly the same length. Also verify that the file is
patched correctly by using the 'dd if=login' command from before:

   $ ls -l login /sbin/login
-rwxr-x--- 1 root root 22016 Aug 11 2003 /usr/bin/login
-rw-r--r-- 1 user default 22016 Jul 7 01:39 login

   $ dd if=login skip=1224 bs=1 count=10 | tr '\000' 0
   pwd:0ord:0

Right. Notice now that 'pwd:0' (your null-terminated replacement
string) has replaced the "Password:0" string. There is still some of
the old string there, the 'ord:0'. This is no problem, though, since
the *printf() system call(s) will stop at the null.

Now test the new login before installing it to your system:

   $ chmod u+x login
   $ ./login
   login: root
   pwd:

If it seems to work, install it to the system but save a backup copy
in case something goes wrong in the future:

   $ su root
   # chown --reference=/sbin/login login
   # chmod --reference=/sbin/login login
   # cp -a --backup=~orig~ login /sbin/login

Before copying, the chown and chmod commands will make sure that the
replacement program /sbin/login that you modified has the same owner
(chown) and mode (chmod) as the original /sbin/login.



Relevant Pages

  • Re: Help: Login failed for User ???
    ... I tried using the new version of the connect string and have the same ... Only the database that needs accessing is checked for permission. ... I login Windows, Run application, I can get ... Since you are using Windows Auth, ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Windows versus Application Security
    ... Public Property UserNameAs String ... What is the equivalent in a Windows Application? ... So you would just have a login entry from that check the user likely from ... managing and removing windows domain accounts are not the ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: Login failed for user NT AUTHORITYNETWORK SERVICE.
    ... assign some roles to the login, e.g. membership_basic or whatever suits your needs. ... ection owningObject, SqlConnectionString connectionOptions, String ... newPassword, Boolean redirectedUserInstance) +628 ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: Using the computer login for security
    ... This VB utility can retrieve the users' login and launch the ... > ByVal lpUserName As String, ... > ' Buffer size for the return string. ...
    (microsoft.public.access.security)
  • Re: multi-word substitution
    ... > chomp $replacement; ... I'm not very happy with your command structure: ... your code will substitute the string 'words to be substitute' ...
    (perl.beginners)