www.webdeveloper.com
Results 1 to 5 of 5

Thread: Help with code.

  1. #1
    Join Date
    May 2003
    Posts
    33

    Help with code.

    Sorry I took so long. My brother was using the computer.

    I have written a srcipt PHP like here:
    ----------------------
    "We haven't got much information on device. It's connected to the network by a backend: finger.php.
    To open a door you ask the backend to send you the required fingerprint.
    GET /s1/s2/s3/s4/s5/finger.php HTTP/1.0

    Then you have to return this fingerprint in encoded format (within 5 seconds) like this:

    POST /s1/s2/s3/s4/s5/finger.php?action=answer HTTP/1.0
    input=(encoded fingerprint)

    A general description of the encoding is below, stolen from the DMN Security Archives:

    --
    count($lines) = count($R) + count($C)
    foreach($R as $r){
    print count($groups)
    foreach($groups as $group){
    print " "
    print count($group)
    }
    print "\n"
    }
    foreach($C as $c){
    print count($groups)
    foreach($groups as $group){
    print " "
    print count($group)
    }
    print "\n"
    }
    --

    It's still a bit cryptic, but we know you're able to solve it. It will be a lot easier if you found out what the R and C variables mean.

    P.S. Please note that the returned, encoded fingerprint may NOT contain any extra spaces or
    returns. It must be created exactly as described in this document.

    (Hint: don't forget to transfer your cookie, otherwise the system will be unable to find out who solved the mission)"
    -----------------------------------
    a file dowload from "finger.php" like here:

    13
    30
    X X XX X XXX X X X X X X
    XXX XXXXX X XX XXX X XXX
    X X XX XXX X X X XXXXX
    X X X XXXX X X XXXX XX
    X XXXX X XXX XX XX X
    XXX XXXX XXXXX X XXX XXX X
    X XXX XXXX X X XX
    X X X X XXX XX XXXX X
    X X XXXX XX XX X X X
    X XXX X XX XXXX XX X XX
    X XXX X XX X XX X XXX XXX
    X X X XX XX X X X X
    XXXXXXXXX XXX XXXXXXX X XX


    ------------------------------------(there isnt this line in file)

    or

    20
    19
    X XXX X XXXX XXX X
    X X X XX X
    XX XXX X XX X
    XXX XXXX X XXXXXXX
    X X XXXX X X X X
    X XXX X
    X XXX XXX XX X
    XX X XXXX
    XXXX X XXXXX
    XXXX XX XX XXXX X
    XX X XX X XXX
    X X X X XX
    XX XXX
    X X XX XXX XX
    X XXX X XX XX
    XXXXXXX XX X XX
    XX XX X X XX X
    X X XXXX XX X X
    X X XX X XX X
    X X X XXXXX X
    ---------------------------------------

    Solution in Development.

    <?PHP

    function mgroups($a,$b,$line)
    { $groups="";
    for($i=0;$i<strlen($line);$i++)
    {$tab=substr($line,$i,1);}
    if(($a<$b)&&($b<strlen($line)))
    {for($i=$a;$i<=$b;$i++)
    {$groups.=$tab[$i];}
    }
    else
    { print "can't make groups";}
    return $groups;
    }

    function resgroups($line)
    { $len=strlen ($line);
    for($i=0;$i<$len;$i+1+($k-$i))
    { if($line[$i]==" ")
    $k=$i;
    while($line[$i]=="x")
    { for($k=$i;$k<$len-$i;$k++)
    { if (($line[$k]=="x")&&($line[$k+1]==" "))
    $groups[]=mgroups($i,$k,$line);
    }
    }
    }
    $ngroups=count($groups);
    print($ngroups);
    for($i=0;$i<$ngroups;$i++)
    { print (" ") ;
    $d=strlen($groups[$i]);
    print ($d);
    }


    }
    function reponse($file)
    { $tab=explode("\n",$file);
    $a=count($tab);
    $b=strlen($tab[2]);
    for($i=2;$i<$a;$i++)
    for($j=0;$j<$b;$j++)
    $intab[$j][$i-2]=$tab[$i][$j];
    for($i=2;$i<$a;$i++)
    { resgroups²($tab[$i]);
    print("\n");
    }
    for($j=0;$j<$b²;$j++)
    { resgroups($intab[$j]);
    print("\n");
    }

    }
    $port=80;
    $hote="sers.sourceforge.net";
    $url_abs="/s1/s2/s3/s4/s5/finger.php";
    $requete="GET sers.sourceforge.net/s1/s2/s3/s4/s5/finger.php HTTP/1.0";
    setcookie($user,$passwd,"sers.sourceforge.net",$url_abs,time()+3000);
    $fp=fsockopen("sers.sourceforge.net",$port);
    if(!fp)
    {return false;
    echo "connect false";
    }
    setcookie($user,$passwd,"sers.sourceforge.net",$url_abs,time()+3000);
    fputs($fp,$requete);
    print ($fp);
    $file=fgets($fp,1024);
    print ($file);
    $view=reponse($file);
    print ($view);
    $answer="POST sers.sourceforge.net/s1/s2/s3/s4/s5/finger.php?action=answer HTTP/1.0 input=reponse($file)";
    setcookie($user,$passwd,"sers.sourceforge.net",$url_abs,time()+3000);
    fputs($fp,$answer);
    echo "<html><head><body>$view</body></head></html>"

    ____________________________________________________

    now the first thing I talk about the part encoding!
    the file " finger" is alway change dimension!
    ex, when I download a file from server: it is here:
    3
    4
    xxxx
    x x
    xx x

    you can see, there are 3 lines
    1:xxxx
    2: x x
    3:xx x
    anyway you can see, there 4 colomn:
    1 2 3 4
    x x x x
    x x
    x x x

    need to encode this file I have to use groups
    groups =the groups of "x" consicutive,if there is only one "x", we also considerate it is a group.
    then I have count the number of "x" in a group.
    ex: "xx" there are 2
    "x" there is 1
    "xxx" there are 3
    -----------
    return of the file:
    now we encode each line.
    for each line we must find out there are how many groups in this line. And then for each group we count the number of "x".
    ex:
    the first line
    xxxx : there is 1 group, in this the first group there are 4 "x"
    we encode this line:
    1 4
    the second line
    x x : there are 2 groups, in the first group there is 1 "x", in the second groups there is 1 "x".
    whe encode this line:
    2 1 1

    we do the same work with the other line.
    ----------------------
    next, we encode each colomn.
    the first colomn:
    x

    x

    there are 2 groups, and the first group there is 1 "x", the second group there is 1 "x".
    we encode: 2 1 1
    the second colomn:
    x
    x
    x
    there is 1 group, the frist group there is 3 "x".
    we encode: 1 3.

    we do the same with the other colomn.

    now the file "finger" is
    3
    4
    xxxx
    x x
    xx x

    we encode this file here:
    1 4
    2 1 1
    2 2 1
    2 1 1
    1 3
    1 1
    1 3
    ----------------------
    that is the part of encoding.

    here is the part of download the file "finger" and send reponse to server:

    the first thing I must download the file finger by function of HTTP like "GET .../s1/.../s5/finger.php HTTP 1.0"

    (within 5 seconds)
    After encoding the file I need send this reponse to server: like
    POST ..../s1/../s5/finger.php?action=answer HTTP 1.0 input=(file encode)
    and I have to send my cookie for sever know who have solve the problem!

    Thanks in advance for any help.

  2. #2
    Join Date
    Feb 2003
    Location
    Britain
    Posts
    1,335
    What do you want help with?

  3. #3
    Join Date
    May 2003
    Posts
    33

    There is an error is the php code to send the cookie.

    I can't figure out how to fix it.

  4. #4
    Join Date
    Feb 2003
    Location
    Britain
    Posts
    1,335
    I don't understand what you want it to do.

  5. #5
    Join Date
    May 2003
    Posts
    33

    I want to...

    Send my cookie with the answer to the server.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles