Jump to content

C to Module?


rab

Recommended Posts

Alright I have a certin peice of C code that is hard to port. I was wondering if there was a safe way of executing it and rettrieving information from it or compiling it as a php module. Is there any way to do this?
Link to comment
Share on other sites

The out put of the program is
[code]
69.164.100.200   5150
    83.71.83.19   56129
   24.14.144.22   1401
   70.125.156.6   5150
  24.33.131.239   5150
206.174.154.174   5150
  70.20.233.160   50206
   24.55.91.108   5150
   24.86.86.200   62841
  24.15.190.153   5150
  70.50.128.152   63630
     72.81.9.43   5150
   65.2.139.121   50108
   12.219.67.24   32929
  68.11.123.247   60542
81.164.109.163   5150
69.192.166.103   63553
   4.225.34.193   5150
   68.47.43.164   5150
  71.234.75.198   62015
65.175.251.198   5150
24.131.247.197   5150
  172.149.37.31   5150
  68.197.169.86   5150
  66.245.63.108   12417
[/code]

I need to parse through that for a specific IP how would I do this.

Note I tried exec, system, passthru and non of them return this.
Link to comment
Share on other sites

[!--quoteo(post=373634:date=May 13 2006, 09:07 PM:name=rab)--][div class=\'quotetop\']QUOTE(rab @ May 13 2006, 09:07 PM) [snapback]373634[/snapback][/div][div class=\'quotemain\'][!--quotec--]
The out put of the program is
[code]
69.164.100.200   5150
    83.71.83.19   56129
   24.14.144.22   1401
   70.125.156.6   5150
  24.33.131.239   5150
206.174.154.174   5150
  70.20.233.160   50206
   24.55.91.108   5150
   24.86.86.200   62841
  24.15.190.153   5150
  70.50.128.152   63630
     72.81.9.43   5150
   65.2.139.121   50108
   12.219.67.24   32929
  68.11.123.247   60542
81.164.109.163   5150
69.192.166.103   63553
   4.225.34.193   5150
   68.47.43.164   5150
  71.234.75.198   62015
65.175.251.198   5150
24.131.247.197   5150
  172.149.37.31   5150
  68.197.169.86   5150
  66.245.63.108   12417
[/code]

I need to parse through that for a specific IP how would I do this.

Note I tried exec, system, passthru and non of them return this.
[/quote]

Try this Rab,

[code]
<?php
$string = " 69.164.100.200   5150
    83.71.83.19   56129
   24.14.144.22   1401
   70.125.156.6   5150
  24.33.131.239   5150
206.174.154.174   5150
  70.20.233.160   50206
   24.55.91.108   5150
   24.86.86.200   62841
  24.15.190.153   5150
  70.50.128.152   63630
     72.81.9.43   5150
   65.2.139.121   50108
   12.219.67.24   32929
  68.11.123.247   60542
81.164.109.163   5150
69.192.166.103   63553
   4.225.34.193   5150
   68.47.43.164   5150
  71.234.75.198   62015
65.175.251.198   5150
24.131.247.197   5150
  172.149.37.31   5150
  68.197.169.86   5150
  66.245.63.108   12417";
  
/* The IP we want to find */
$IPSearch = "68.47.43.164";

/* Break the string into an array, each line is a new element */
$IPListArr = explode("\n", $string);
/* Loop through the array */
for($i=0; $i <= count($IPListArr); $i++){
    /* Trim whitespace */
    $Line = trim($IPListArr[$i]);
    /* Break up the IP and Port*/
    $IPVals = explode("   ", $Line);
    /* Is it the one we want to find? */
    if($IPVals[0] == $IPSearch){
        /* yes, echo it out */
        echo "IP Found: ". $Line;
    }
}
?>
[/code]

That is assuming you can get the output of the program into a string in php
Link to comment
Share on other sites

[!--quoteo(post=373733:date=May 14 2006, 08:45 AM:name=rab)--][div class=\'quotetop\']QUOTE(rab @ May 14 2006, 08:45 AM) [snapback]373733[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Finding it wont be a problem, getting the return into a string is.
[/quote]

To quote one of your earlier posts..

"I need to parse through that for a specific IP how would I do this."

*shrug*
Link to comment
Share on other sites

Now my question is, when i let users enter things, like IP's , how can i stop them from doing things they are supossed to. Example, if they enter "124.35.64.23; wget netcat; ./netcat", that will download netcat and execute it. How can i stop things like that.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.