помогите с парсилкой

Discussion in 'PHP' started by maxi163, 23 Feb 2009.

  1. maxi163

    maxi163 Banned

    Joined:
    10 Jul 2008
    Messages:
    0
    Likes Received:
    7
    Reputations:
    0
    есть логи из которых я хочу выдрать "email=" и "pass="
    структура такова что под емейлом находится пасс
    Я юзаю такой скрипт
    Code:
    <?php
    
    /*
    ZeuS Passwords Parser
    by Helkern
    (c) ItHack.ws
    */
    
    error_reporting(0);
    set_time_limit(0);
    
    $usage=" [ ZeuS Passwords Parser v1.0 ]\r\n\r\n";
    $usage.="\t\t-l   Logs file.\r\n";
    $usage.="\t\t-o   Outfile.\r\n\r\n";
    $usage.=" (c) ItHack.ws, by Helkern\r\n\r\n";
    
    if($argc==1) {
    echo $usage;
    exit();
    }
    
    $i=0;
    while($i<=$argc) {
    if($argv[$i]=="-l")
    $logs_file=$argv[$i+1];
    elseif($argv[$i]=="-o")
    $out_file=$argv[$i+1];
    
    $i++;
    }
    
    $url_pattern="^http://[a-zA-Z0-9\._-]+\.[a-zA-Z]{2,4}";
    $user_pattern="^email=";
    $pass_pattern="^pass=";
    
    echo $usage;
    
    $fp=fopen($logs_file, "r") or die(" [~] Can't open logs file ($logs_file)\r\n");
    $fo=fopen($out_file, "a+") or die(" [~] Can't open outfile ($out_file)\r\n");
    
    while(!feof($fp)) {
    $data=trim(fgets($fp, 1024));
    if(eregi($url_pattern, $data))
    fwrite($fo, $data."\r\n");
    if(eregi($user_pattern, $data))
    fwrite($fo, $data."\r\n");
    if(eregi($pass_pattern, $data))
    fwrite($fo, $data."\r\n");
    }
    
    echo " [~] See the $out_file and have the fun =)\r\n";
    
    fclose($fp);
    fclose($fo);
    
    ?>
    дак проблема в том что в логах имеются значени такие как email=[пустота] и pass=[пустота], появляется куча дублей. Если кто может помогите, нужно доработать скрипт чтобы он тянул емайл и пасс и записывал в таком виде email;pass и соответственно без дубликатов

    вид лога:
    Code:
    -------------ttp://vkontakte.ru/--------------
    Session cookies: remixchk=5
    Key pressed: ak2812@mail.ru726788<enter><enter>
    Field hooked: email=ak2812@mail.ru
    pass=726788
    
    email=ak2812@mail.ru
    pass=726788
    ----------------------------------------------------
    
    -------------ttp://vkontakte.ru/id957285--------------
    Session cookies: remixchk=5; remixmid=957285; remixemail=ak2812%40mail.ru; remixpass=34a1586358b4d492b9713e6af945a62d
    Key pressed: 
    Field hooked: email=ak2812@mail.ru
    pass=726788
    
    q=Поиск
    act=quick
    to_m_id=957285
    edit_activity_text=
    to_op_id=957285
    to_id=9572850715
    act=sent
    
    
    ************2008.07.26 23:03:18 :: 78.85.65.13************
    ----------------------------------------------------
    
    -------------ttp://vkontakte.ru/id957285--------------
    Session cookies: remixchk=5; remixmid=957285; remixemail=ak2812%40mail.ru; remixpass=34a1586358b4d492b9713e6af945a62d
    Key pressed: 
    Field hooked: q=Поиск
    act=quick
    =957285
    =1
    to_m_id=957285
    =7bea19086b6ccdf6d5c1a23e2541b6d4
    edit_activity_text=
    to_op_id=957285
    to_id=9572850715
    act=sent
    
    q=Поиск
    act=quick
    to_m_id=957285
    edit_activity_text=
    to_op_id=957285
    to_id=9572850715
    act=sent
    q=Поиск
    act=quick
    to_m_id=957285
    edit_activity_text=
    to_op_id=957285
    to_id=9572850715
    act=sent
     
    1 person likes this.
  2. [dei]

    [dei] Active Member

    Joined:
    24 Nov 2008
    Messages:
    171
    Likes Received:
    112
    Reputations:
    5
    ну как то так =\

    PHP:
    <?php

    /*
    ZeuS Passwords Parser
    by Helkern
    (c) ItHack.ws
    */

    error_reporting(0);
    set_time_limit(0);

    $usage=" [ ZeuS Passwords Parser v1.0 ]\r\n\r\n";
    $usage.="\t\t-l   Logs file.\r\n";
    $usage.="\t\t-o   Outfile.\r\n\r\n";
    $usage.=" (c) ItHack.ws, by Helkern\r\n\r\n";

    if(
    $argc==1) {
    echo 
    $usage;
    exit();
    }

    $i=0;
    while(
    $i<=$argc) {
    if(
    $argv[$i]=="-l")
    $logs_file=$argv[$i+1];
    elseif(
    $argv[$i]=="-o")
    $out_file=$argv[$i+1];

    $i++;
    }

    echo 
    $usage;

    $fo=fopen($out_file"a+") or die(" [~] Can't open outfile ($out_file)\r\n");

    $data=file_get_contents($logs_file) or die(" [~] Can't open logs file ($logs_file)\r\n");

    preg_match_all('/email=(.+?)\s+pass=(.+)/'$data$matches);
    $c count($matches[0]);
    for(
    $i=0;$i<$c;$i++) {
    fwrite($fo$matches[1][$i].':'.$matches[2][$i]."\n");
    }

    echo 
    " [~] See the $out_file and have the fun =)\r\n";

    fclose($fo);

    ?>
     
    1 person likes this.
  3. maxi163

    maxi163 Banned

    Joined:
    10 Jul 2008
    Messages:
    0
    Likes Received:
    7
    Reputations:
    0
    [dei] респект и уважуха
    после 3-х парсеров и ручек получил то что хотел!
     
    1 person likes this.
  4. Blackcat95

    Blackcat95 Member

    Joined:
    11 Nov 2008
    Messages:
    19
    Likes Received:
    10
    Reputations:
    0
    А в зевсе разве пассы не в мд5?
     
  5. maxi163

    maxi163 Banned

    Joined:
    10 Jul 2008
    Messages:
    0
    Likes Received:
    7
    Reputations:
    0
    у меня не зевс
     
    2 people like this.
  6. maxi163

    maxi163 Banned

    Joined:
    10 Jul 2008
    Messages:
    0
    Likes Received:
    7
    Reputations:
    0
    ещё просьба:
    нужен скрипт который удаляет из txt файла такие строчки:
    xxxx@yyyy:[пустота], где yyyy это может быть mail.ru, yahoo.com и т.д.
     
  7. [dei]

    [dei] Active Member

    Joined:
    24 Nov 2008
    Messages:
    171
    Likes Received:
    112
    Reputations:
    5
    PHP:
    <?php
    $file1
    ='in.txt';
    $file2='out.txt';

    $f fopen($file2,'w');
    foreach(
    file($file1) as $line) {
        if(
    preg_match('/.*@.*:.+/U',trim($line))) fputs($f,$line);
    }
    ?>
     
  8. maxi163

    maxi163 Banned

    Joined:
    10 Jul 2008
    Messages:
    0
    Likes Received:
    7
    Reputations:
    0
    ещё раз благодарю