<?php
class structorian {
public $fd = NULL;
public $mode = NULL;
public function __construct($filename, $mode = "rb") {
$this->mode = $mode;
switch($mode) {
case "wb":
$this->fd = fopen($filename, $mode);
break;
default:
$this->fd = fopen($filename, $mode);
break;
}
}
public function read($dataType = NULL, $count = NULL) {
$data = NULL;
if((!!$this->fd) && (!feof($this->fd))) {
switch ($dataType) {
case "i8":
$data = unpack("ci8", fread($this->fd, 1))['i8'];
break;
case "i16":
$data = unpack("si16", fread($this->fd, 2))['i16'];
break;
case "i32":
$data = unpack("ii32", fread($this->fd, 4))['i32'];
break;
case "ichar":
$data = chr(unpack("cchar", fread($this->fd, 1))['char']);
break;
case "u8":
$data = unpack("Cu8", fread($this->fd, 1))['u8'];
break;
case "u16":
$data = unpack("Su16", fread($this->fd, 2))['u16'];
break;
case "u32":
$data = unpack("Iu32", fread($this->fd, 4))['u32'];
break;
case "char":
case "uchar":
$data = chr(unpack("Cchar", fread($this->fd, 1))['char']);
break;
case "str":
case "cstr":
$data = unpack("a".$count."str", fread($this->fd, $count))['str'];
break;
case "float":
$data = unpack("ffloat", fread($this->fd, 4))['float'];
break;
case "double":
$data = unpack("ddouble", fread($this->fd, 8))['double'];
break;
default:
break;
}
}
return $data;
}
public function __destruct() {
if(!!$this->fd) return fclose($this->fd);
}
/*
public function x8() {
}
public function x16() {
}
public function x32() {
}
public function bits8() {
}
public function bits16() {
}
public function bits32() {
}
public function enum8() {
}
public function enum16() {
}
public function enum32() {
}
public function set8() {
}
public function set16() {
}
public function set32() {
}
public function wstr() {
}
public function wchar() {
}
*/
}
You can use the content of the DB (arcadia) to figure out the structure of the content of the RDBs and other flies on the client, it helps a lot.
Also, if you're really willing to use structorian AND a web language, maybe you should take a look into the c# version of structorian made by Yole (on google code). You might have the full power of structorian combined with whatever web you feel like doing.
Hi all,
I need an helping hand from you: what is the right flow to get all the database fields named right? As you know I am playing with RDB... trying to find out their structure, but now I need to know the way to name these fields I am discovering.
CaptainHerlockServer.pdb and then ???
Thanks a lot for your answers.
Regards,
Skamorzo.
PS. I am playing with 6.2 server files... and if it is possible, may I have the .strs files for 6.2? ^.^
The RDB's normally follow a similar if not precise database structure. But some rdb's do not play nice (quest.rdb etc..)
The only way to build an RDB reader is to literally go into the rdb and translate it as you go using the DB counterpart as a pseudo-guide. Contact me via Skype and I'll let you at our Senior Tool Programmer he should be able to provide you in-depth insight into creating methods of reading the rdbs.
<?php
/* Author: Skamorzo */
/* To: elitepvpers.com - Rappelz Private Server Teams */
/* This code is intended only for educational use. Use it at your own risk! */
/* All trademarks and copyrights belong to their respective owners */
<?php
/* Author: Skamorzo */
/* To: elitepvpers.com - Rappelz Private Server Teams */
/* This code is intended only for educational use. Use it at your own risk! */
/* All trademarks and copyrights belong to their respective owners */
class structorian {
public $fd = NULL;
public $mode = NULL;
public function __construct($filename, $mode = "rb") {
$this->mode = $mode;
switch($mode) {
case "wb":
$this->fd = fopen($filename, $mode);
break;
default:
$this->fd = fopen($filename, $mode);
break;
}
}
public function read($dataType = NULL, $count = NULL) {
$data = NULL;
if(! feof($this->fd)) {
switch ($dataType) {
case "i8":
$data = @unpack("ci8", @fread($this->fd, 1))['i8'];
break;
case "i16":
$data = @unpack("si16", @fread($this->fd, 2))['i16'];
break;
case "i32":
$data = @unpack("ii32", @fread($this->fd, 4))['i32'];
break;
case "ichar":
$data = chr(@unpack("cchar", @fread($this->fd, 1))['char']);
break;
case "u8":
$data = @unpack("Cu8", @fread($this->fd, 1))['u8'];
break;
case "u16":
$data = @unpack("Su16", @fread($this->fd, 2))['u16'];
break;
case "u32":
$data = @unpack("Iu32", @fread($this->fd, 4))['u32'];
break;
case "char":
case "uchar":
$data = chr(@unpack("Cchar", @fread($this->fd, 1))['char']);
break;
case "str":
case "cstr":
$data = @unpack("a{$count}str", @fread($this->fd, $count))['str'];
break;
case "float":
$data = @unpack("ffloat", @fread($this->fd, 4))['float'];
break;
case "double":
$data = @unpack("ddouble", @fread($this->fd, 8))['double'];
break;
case "x8": /* Still not implemented */
case "x16": /* Still not implemented */
case "x32": /* Still not implemented */
case "bits8": /* Still not implemented */
case "bits16": /* Still not implemented */
case "bits32": /* Still not implemented */
case "enum8": /* Still not implemented */
case "enum16": /* Still not implemented */
case "enum32": /* Still not implemented */
case "set8": /* Still not implemented */
case "set16": /* Still not implemented */
case "set32": /* Still not implemented */
case "wstr": /* Still not implemented */
case "wchar": /* Still not implemented */
break;
default: /* No default action for now */
break;
}
}
return $data;
}
public function write($dataType = NULL, $data = NULL, $count = NULL) {
$status = NULL;
if(($this->fd !== NULL) && ($data !== NULL)) {
switch ($dataType) {
case "i8":
$status = fwrite($this->fd, pack("c", $data));
break;
case "i16":
$status = fwrite($this->fd, pack("s", $data));
break;
case "i32":
$status = fwrite($this->fd, pack("i", $data));
break;
case "ichar":
$status = fwrite($this->fd, pack("c", $data));
break;
case "u8":
$status = fwrite($this->fd, pack("C", $data));
break;
case "u16":
$status = fwrite($this->fd, pack("S", $data));
break;
case "u32":
$status = fwrite($this->fd, pack("I", $data));
break;
case "char":
case "uchar":
$status = fwrite($this->fd, pack("C", $data));
break;
case "str":
case "cstr":
$status = fwrite($this->fd, pack("a{$count}", $data));
break;
case "float":
$status = fwrite($this->fd, pack("f", $data));
break;
case "double":
$status = fwrite($this->fd, pack("d", $data));
break;
case "x8": /* Still not implemented */
case "x16": /* Still not implemented */
case "x32": /* Still not implemented */
case "bits8": /* Still not implemented */
case "bits16": /* Still not implemented */
case "bits32": /* Still not implemented */
case "enum8": /* Still not implemented */
case "enum16": /* Still not implemented */
case "enum32": /* Still not implemented */
case "set8": /* Still not implemented */
case "set16": /* Still not implemented */
case "set32": /* Still not implemented */
case "wstr": /* Still not implemented */
case "wchar": /* Still not implemented */
break;
default: /* No default action for now */
break;
}
}
return $status;
}
public function seek($count) {
return fseek($this->fd, $count);
}
public function get($count) {
return fread($this->fd, $count);
}
public function __destruct() {
if($this->fd) {
fclose($this->fd);
unset($this->fd);
unset($this->mode);
}
return true;
}
}
?>
rdb_discoverer.php - WEB Interface for structorian.phpRDB Read/Write
<HTML>
<HEAD>
<TITLE>RDB Structure Discoverer</TITLE>
</HEAD>
<BODY>
<?php
/* Author: Skamorzo */
/* To: elitepvpers.com - Rappelz Private Server Teams */
/* This code is intended only for educational use. Use it at your own risk! */
/* All trademarks and copyrights belong to their respective owners */
require "structorian.php";
if(! isset($_POST['rdb_filename'])) {
echo "<SCRIPT type='text/javascript'>\n";
echo " function update(value) {\n";
echo " return(value.substring(12));\n";
echo " }\n";
echo " </SCRIPT>\n";
echo "<FORM action='". $_SERVER['PHP_SELF']. "' method='POST'>\n";
echo " <INPUT type='file' name='rdb_filename' onchange='update(this.value)'></INPUT><BR>\n";
echo " <INPUT type='submit' value='Submit'></INPUT><BR>\n";
echo "</FORM>\n";
} else {
if(! isset($_POST['rdb_type'])) {
$rdb_filename= urldecode($_POST['rdb_filename']);
$rdb_format= "";
$rdb_header= 132;
$rdb_size= filesize($rdb_filename);
$rdb_file= new structorian($rdb_filename, "rb");
$rdb_file->seek(128);
$rdb_records= $rdb_file->read("i32");
$rdb_bytes= ($rdb_size - $rdb_header) / $rdb_records;
$rdb_record= bin2hex($rdb_file->get($rdb_bytes));
unset($rdb_file);
} else {
$rdb_type= $_POST['rdb_type'];
$rdb_bytes= $_POST['rdb_bytes'];
$rdb_record= $_POST['rdb_record'];
$rdb_format= $_POST['rdb_format'];
$rdb_filename= urldecode($_POST['rdb_filename']);
if(empty($rdb_format)) {
$rdb_format= $rdb_type;
} else {
$rdb_format.= "/". $rdb_type;
}
}
if(isset($rdb_filename)) echo "<H1>File in use: $rdb_filename</H1>\n";
echo "<H1>Format in use:</H1>\n";
$structure= $rdb_record;
$rdb_length= 0;
$idx= 1;
echo "<B>struct ENTRY {<BR>\n";
foreach(split('[/]', $rdb_format) as $entry) {
$offset= 0;
$value= @unpack($entry, hex2bin($structure));
switch ($entry) {
case "ci8":
$offset= 1;
break;
case "si16":
$offset= 2;
break;
case "ii32":
$offset= 4;
break;
case "Cu8":
$offset= 1;
break;
case "Su16":
$offset= 2;
break;
case "Iu32":
$offset= 4;
break;
case "achar":
$offset= 1;
break;
case "a32str":
$offset= 32;
break;
case "a64str":
$offset= 64;
break;
case "a128str":
$offset= 128;
break;
case "a256str":
$offset= 256;
break;
case "a512str":
$offset= 512;
break;
case "a1024str":
$offset= 1024;
break;
case "ffloat":
$offset= 4;
break;
case "ddouble":
$offset= 8;
break;
case "x8": /* Still not implemented */
case "x16": /* Still not implemented */
case "x32": /* Still not implemented */
case "bits8": /* Still not implemented */
case "bits16": /* Still not implemented */
case "bits32": /* Still not implemented */
case "enum8": /* Still not implemented */
case "enum16": /* Still not implemented */
case "enum32": /* Still not implemented */
case "set8": /* Still not implemented */
case "set16": /* Still not implemented */
case "set32": /* Still not implemented */
case "wstr": /* Still not implemented */
case "wchar": /* Still not implemented */
break;
default: /* No default action for now */
break;
}
foreach($value as $key=>$val) {
echo " <FONT stype='font-size: 0.8em'> $key ". ($offset > 8 ? "[len=$offset]" : ""). "datum_$idx; // <CODE>$val</CODE></FONT><BR>\n";
$idx++;
}
$rdb_length+= $offset;
while($offset > 0) {
$structure= substr($structure, 2);
$offset--;
}
}
echo " if (CurOffset < FileSize) {<BR>\n sibling;<BR>\n }<BR>\n}<BR>\n</B>";
echo "<H2>Record length= $rdb_length/$rdb_bytes bytes (". ($rdb_bytes-$rdb_length). " left)</H2>\n";
echo "<H3>Record data= <CODE style='font-size: 0.8em'>"."\\x". substr(chunk_split($structure, 2, "\\x"), 0, -2). "</CODE></H3>\n";
echo "<FORM action='rdb_view.php' method='POST'>\n";
echo " <INPUT type='hidden' name='rdb_filename' value='$rdb_filename'></INPUT><BR>\n";
echo " <INPUT type='text' size='256' name='rdb_format' value='$rdb_format'></INPUT><BR>\n";
echo " <INPUT type='radio' name='rdb_type' value='ci8'><FONT stype='font-size: 0.8em'>Reading signed byte= <CODE>". @unpack('ci8', hex2bin($structure))['i8']. "</CODE></FONT></INPUT><BR>\n";
echo " <INPUT type='radio' name='rdb_type' value='si16'><FONT stype='font-size: 0.8em'>Reading signed integer= <CODE>". @unpack('si16', hex2bin($structure))['i16']. "</CODE></FONT></INPUT><BR>\n";
echo " <INPUT type='radio' name='rdb_type' value='ii32'><FONT stype='font-size: 0.8em'>Reading signed long= <CODE>". @unpack('ii32', hex2bin($structure))['i32']. "</CODE></FONT></INPUT><BR>\n";
echo " <INPUT type='radio' name='rdb_type' value='ffloat'><FONT stype='font-size: 0.8em'>Reading float= <CODE>". @unpack('ffloat', hex2bin($structure))['float']. "</CODE></FONT></INPUT><BR>\n";
echo " <INPUT type='radio' name='rdb_type' value='ddouble'><FONT stype='font-size: 0.8em'>Reading double= <CODE>". @unpack('ddouble', hex2bin($structure))['double']. "</CODE></FONT></INPUT><BR>\n";
echo " <INPUT type='radio' name='rdb_type' value='achar'><FONT stype='font-size: 0.8em'>Reading char= <CODE>". @unpack('achar', hex2bin($structure))['char']. "</CODE></FONT></INPUT><BR>\n";
echo " <INPUT type='radio' name='rdb_type' value='a32str'><FONT stype='font-size: 0.8em'>Reading str[32]= <CODE>". @unpack('a32str', hex2bin($structure))['str']. "</CODE></FONT></INPUT><BR>\n";
echo " <INPUT type='radio' name='rdb_type' value='a64str'><FONT stype='font-size: 0.8em'>Reading str[64]= <CODE>". @unpack('a64str', hex2bin($structure))['str']. "</CODE></FONT></INPUT><BR>\n";
echo " <INPUT type='radio' name='rdb_type' value='a128str'><FONT stype='font-size: 0.8em'>Reading str[128]= <CODE>". @unpack('a128str', hex2bin($structure))['str']. "</CODE></FONT></INPUT><BR>\n";
echo " <INPUT type='radio' name='rdb_type' value='a256str'><FONT stype='font-size: 0.8em'>Reading str[256]= <CODE>". @unpack('a256str', hex2bin($structure))['str']. "</CODE></FONT></INPUT><BR>\n";
echo " <INPUT type='radio' name='rdb_type' value='a512str'><FONT stype='font-size: 0.8em'>Reading str[512]= <CODE>". @unpack('a512str', hex2bin($structure))['str']. "</CODE></FONT></INPUT><BR>\n";
echo " <INPUT type='radio' name='rdb_type' value='a1024str'><FONT stype='font-size: 0.8em'>Reading str[1024]= <CODE>". @unpack('a1024str', hex2bin($structure))['str']. "</CODE></FONT></INPUT><BR>\n";
echo " <INPUT type='hidden' name='rdb_bytes' value='$rdb_bytes'></INPUT>\n";
echo " <INPUT type='hidden' name='rdb_record' value='$rdb_record'></INPUT>\n";
echo " <INPUT type='submit' value='Submit'></INPUT><BR>\n";
echo "</FORM>\n";
}
?>
</BODY>
</HTML>
These classes still need to be optimized, but they are all functional.
The RDB file need to be in the same folder as the structorian.php and the rdb_discoverer.php files.
I will PM all the structure I discover to from now on.
GUYS.....WE NEED TO THNX AgDev team for thier great work.....just thnx them!? 12/04/2008 - Silkroad Online - 5 Replies AgDev team:handsdown:we all thnx u for hard work....and making boting more easy......and the scripts thing.......WE JUST THNXXX:bandit::D:):mofo::handsdown::handsdown::han dsdown::handsdown::handsdown::handsdown::handsdown ::handsdown::p
If thesse work it be great 04/13/2006 - Conquer Online 2 - 14 Replies I was just wondering is it posssble to make a archer bot that scatters high levl monsters and than run away????