Server IP : 103.119.228.120 / Your IP : 18.218.190.118 Web Server : Apache System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64 User : nobody ( 99) PHP Version : 5.6.40 Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/local/bin/ |
Upload File : |
#!/usr/bin/perl # ============================================================================ # $Id: snmpkey.PL,v 6.0 2009/09/09 15:07:48 dtown Rel $ # Copyright (c) 2001-2009 David M. Town <dtown@cpan.org> # All rights reserved. # This program is free software; you may redistribute it and/or modify it # under the same terms as the Perl 5 programming language system itself. # ============================================================================ =head1 NAME snmpkey - Create SNMPv3 security keys for the Net::SNMP module =head1 USAGE The C<snmpkey> utility generates security keys based on a password and an authoritativeEngineID passed on the command line. This key can then be used by the Net::SNMP module instead of the plain text password when creating SNMPv3 objects. snmpkey <authProto> <password> <authEngineID> [<privProto> [<password>]] =head1 DESCRIPTION The User-based Security Model used by SNMPv3 defines an algorithm which "localizes" a plain text password to a specific authoritativeEngineID using a one-way hash. This resulting key is used by the SNMP application instead of the plain text password for security reasons. The Net::SNMP module allows the user to either provide a plain text password or a localized key to the object constructor when configuring authentication or privacy. The C<snmpkey> utility can be used to generate the key to be used by the B<-authkey> or B<-privkey> named arguments when they are passed to the Net::SNMP C<session()> constructor. =head1 REQUIRED ARGUMENTS The C<snmpkey> utility requires at least three command line arguments. The first argument defines which hash algorithm to use when creating the authKey. Either HMAC-MD5-96 or HMAC-SHA-96 can be specified with the string 'md5' or 'sha' respectively. This choice must match the algorithm passed to the B<-authprotocol> argument when creating the Net::SNMP object. The second argument is the plain text password that is to be localized to create the authKey. The third required argument is the authoritativeEngineID of the remote SNMP engine associated with the Net::SNMP argument B<-hostname>. The authoritativeEngineID is to be entered as a hexadecimal string 10 to 64 characters (5 to 32 octets) long and can be prefixed with an optional "0x". The last two arguments are optional and can be used to determine how the privKey will be generated. By default, the fourth argument assumes a value of 'des' corresponding to the default privacy protocol defined in the User-based Security Model. The Net::SNMP module supports CBC-3DES-EDE and CFB128-AES-128 as alternatives to the default protocol CBC-DES. These protocols can be chosen by specifying the string '3des' or 'aes' respectively. This choice must match the protocol passed to the B<-privprotocol> argument when creating the Net::SNMP object. The last argument can be used to specify the plain text password that is to be localized to create the privKey. If this argument is not specified, the authKey password is used. =head1 AUTHOR David M. Town <dtown@cpan.org> =head1 LICENSE AND COPYRIGHT Copyright (c) 2001-2009 David M. Town. All rights reserved. This program is free software; you may redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =head1 SEE ALSO L<Net::SNMP> =cut # ============================================================================ use strict; use warnings; use Net::SNMP::Security::USM 4.0; our $SCRIPT = 'snmpkey'; our $VERSION = v6.0.0; # Do we have enough/too much information? if ((@ARGV < 3) || (@ARGV > 5)) { usage(); } my ($usm, $error) = Net::SNMP::Security::USM->new( -authoritative => 1, # Undocumented / unsupported argument -username => 'initial', -authprotocol => $ARGV[0], -authpassword => $ARGV[1], -engineid => $ARGV[2], -privprotocol => (@ARGV > 3) ? $ARGV[3] : 'des', -privpassword => (@ARGV > 4) ? $ARGV[4] : $ARGV[1] ); if (!defined $usm) { abort($error); } printf "authKey: 0x%s\n", unpack 'H*', $usm->auth_key(); printf "privKey: 0x%s\n", unpack 'H*', $usm->priv_key(); exit 0; # [functions] ---------------------------------------------------------------- sub abort { printf "$SCRIPT: " . ((@_ > 1) ? shift(@_) : '%s') . ".\n", @_; exit 1; } sub usage { printf "%s v%vd\n", $SCRIPT, $VERSION; print << "USAGE"; Copyright (c) 2001-2009 David M. Town. All rights reserved. All rights reserved. Usage: $SCRIPT <authProto> <password> <authEngineID> [<privProto> [<password>]] <authProto> = md5|sha <privProto> = des|3des|aes USAGE exit 1; } # ============================================================================