Fw: Re: [Win2k - Version 8.0.2] - StartupMessage Format Question

Поиск
Список
Период
Сортировка
От Tom Pfeifer
Тема Fw: Re: [Win2k - Version 8.0.2] - StartupMessage Format Question
Дата
Msg-id 20050515154838.M31208@tela.com
обсуждение исходный текст
Ответ на Re: [Win2k - Version 8.0.2] - StartupMessage Format Question  ("Tom Pfeifer" <tpfeifer@tela.com>)
Ответы Re: Fw: Re: [Win2k - Version 8.0.2] - StartupMessage Format Question  (Volkan YAZICI <volkan.yazici@gmail.com>)
Список pgsql-novice
Thank you all for the help.  If your interested in the solution I have put it here in the email for
future reference.  This is broken down step by step and could be combined so the code is more
efficient.  This is just the first step.  I need to take this and create the appropriate steps for
Authentication etc...  But the hard part is done.  I can now connect to the postgres backend and I
get an appropriate message back which asks for the password.

use IO::Socket;
$string = 'user' . chr(0) . 'postgres' . chr(0) . 'database' . chr(0) .  'maach' . chr(0) . chr(0);
$strlen = length($string);
$string = pack("a$strlen", $string);
$version = pack('n', 3);
$verlen = length($version);
$revision = pack('n', 0);
$revlen = length($revision);
$total = 4 + $strlen + $verlen + $revlen;
$len = pack('N', $total);
$send = $len . $version . $revision . $string;
while ($send =~ m/(.{1,16})/g) {
  my $chunk = $1;
  print join ' ', map {sprintf '%02X', ord $_} split //, $chunk;
  print '   ' x (16 - length $chunk);
  print '  ';
  print join '', map { sprintf '%s', (/[[:graph:] ]/) ? $_ : '.' } split //, $chunk;
  print "\n";
}
$remote = IO::Socket::INET->new(PeerAddr => '127.0.0.1', PeerPort => '5432', Proto => 'tcp',
Timeout  => '30') or die "error:$!";
$remote->autoflush(1);
print $remote "$send\n";
while ( <$remote> ) { 
  print "\n";
  while ($_ =~ m/(.{1,16})/g) {
    my $chunk = $1;
    print join ' ', map {sprintf '%02X', ord $_} split //, $chunk;
    print '   ' x (16 - length $chunk);
    print '  ';
    print join '', map { sprintf '%s', (/[[:graph:] ]/) ? $_ : '.' } split //, $chunk;
    print "\n";
  }
}
$remote->close;
exit(0);

RESULTS::)
00 00 00 26 00 03 00 00 75 73 65 72 00 70 6F 73  ...&....user.pos
74 67 72 65 73 00 64 61 74 61 62 61 73 65 00 6D  tgres.database.m
61 61 63 68 00 00                                aach..

52 00 00 00 0C 00 00 00 05 80 F4 24 B6           R..........$.

Thanks again to all who clued me in on the correct format for the StartupMessage.
T Pfeifer


В списке pgsql-novice по дате отправления:

Предыдущее
От: John DeSoi
Дата:
Сообщение: Re: [Win2k - Version 8.0.2] - StartupMessage Format Question
Следующее
От: Volkan YAZICI
Дата:
Сообщение: Re: Fw: Re: [Win2k - Version 8.0.2] - StartupMessage Format Question