Post Pacific

Post Pacific (https://postpacific.mmorpg-game.online/index.php)
-   Lineage 2 General (https://postpacific.mmorpg-game.online/forumdisplay.php?f=31)
-   -   C4 CacheD, 2012 port commands (https://postpacific.mmorpg-game.online/showthread.php?t=5371)

nucer 11.08.2006 00:11

C4 CacheD, 2012 port commands
 
Who knows something about it? :)

astrid 11.08.2006 00:16

Not sure yet, by exploring cached i think commans must be sent as "packet" not string.

Packet can contain only hex numbers, and appear to be that 1st or 2 first bytes is length of "packet". Need more time for exploring.

zabbix 11.08.2006 08:22

[cSS] 0x49 -> announce, as far as i remember :D

Mayii 11.08.2006 09:16

fairly easy.
you send packets assembled like the standard L2 Format.
open cached in OllyDbg, search for referenced strings, and you'll have everything you need.
gonna give you a short example:
You get this referenced string:
0040FDCA . 68 40805000 PUSH Cached4p.00508040 ; UNICODE "static bool SendHomePacket(CAdminSocket* pSocket, const unsigned char* packet)"

now you scroll down a bit until you get to a call to the disassemble function,
0040FE73 . E8 D8F50200 CALL Cached4p.0043F450

now you look a bit up and find the formatter (it's the second argument to the function),
0040FE6D . 68 645C5000 PUSH Cached4p.00505C64 ; ASCII "dS"

packet formatter 'd' are 4 bytes, assembled to a 32 byte SIGNED integer.
packet formatter 'S' is a sort of PASCAL string. first 2 bytes (or 1 byte, don't remember now...) are the LENGTH (not the size as it is unicode!) of the string, the following bytes are the UNICODE string itself WITHOUT the typical c-string NULL end.

Edit: woop, forgot to say that the complete packet format is not only for example dS, but cdS, c being the packet ID.

nucer 11.08.2006 23:42

Mayii, can you post a sample of formed packet in hex please.

KciNicK 12.08.2006 15:28

i made 2 funtions for u, make the rest yourself..., cya...

Code:

<?php
###############################################
# id | Function Name(Function parms) #
###############################################

#d = int (4 bytes, little endian)
#S = unicode String ending with \0
#f = float

#1 CheckCharacterPacket("dS")
#2 SetCharacterLocationPacket("dddddS")
#3 SetBuilderCharacterPacket("ddS")
#4 ChangeCharacterNamePacket("dSS")
#5 KickCharacterPacket("dS")
#6 AddSkillPacket("dddS")
#7 DelSkillPacket("ddS")
#8 ModSkillPacket("dddS")
#9 SetOnetimeQuestPacket("dddS")
#10 SetQuestPacket("ddd")
#11 DelQuestPacket("ddS")
#12 AddItemPacket()
#13 DelItemPacket("ddddS")
#14 ModItemPacket("ddddddddddS")
#15 ModCharPacket("dddddddS")
#16 ModChar2Packet("dddddddS")
#17 ModCharPledgePacket("dSS")
#18 PunishCharPacket("ddd")
#19 SetBuilderAccountPacket("SdS")
#20 DisableCharacterPacket("ddS")
#21 EnableCharacterPacket("ddS")
#22 GetCharactersPacket()
#23 SetBookMarkPacket("dSddddS")
#24 DelBookMarkPacket("dSS")
#25 DelPledgeCrestPacket("dS")
#26 ModPledgeNamePacket("dSS")
#27 SetProhibitedPacket("dSS")
#28 SeizeItemPacket("ddddS")
#29 ModChar3Packet("dddddddS")
#30 MoveItemPacket("ddddd")
#31 MoveCharacterPacket("ddSS")
#32 CommentWritePacket("dSSS")
#33 CommentDeletePacket("ddS")
#34 DeleteCharPacket("dS")
#35 RestoreCharPacket("ddSS")
#36 PledgeOustPacket("dS")
#37 PledgeChangeOwnerPacket("ddS")
#38 PledgeDeletePacket()
#39 BanCharPacket("ddS")
#40 MoveItem2Packet("ddddS")
#41 PrintAllAccountData()
#42 PrintAllItemData()
#43 CopyCharPacket("dSdSS")
#44 CreatePetPacket("dddS")
#45 SendHomePacket("dS")
#46 ChangePledgeLevelPacket("ddS")
#47 CreatePledgePacket("SdS")
#48 SetSkillAllPacket("dS")
#49 RestoreChar2Packet("dSdSS")
#50 ManAnnouncePacket("ddSS")
#51 ManIntAnnouncePacket("dddSS")
#52 ModWeekPlayPacket("dddS")
#53 SeizeItem2Packet("ddS")
#54 DelItem2Packet("ddS")
#55 AddItem2Packet("dddddddddS")
#56 GetCharacters2Packet("dS")
#57 DelMacroPacket("ddS")
#58 DelMonRaceTicketPacket("dddS")
#59 DelRecipePacket("ddS")
#60 DelLottoPacket()
#61 ModifyPledgePowerPacket("ddSS")
#62 EventPointPacket("df")
#63 GetPledgePacket("dS")
#64 EventPointPacket("df")
#65 CreateCharacterPacket("SSddddddddffddddddddddS")
#66 AddItemsPacket("dSd")
#67 AddSkillsPacket("dSd")
#68 GetCharacters3Packet("dS")
#69 SetSociality("ddS")
#70 SetInstantAnnouncePacket("SS" or "cdS") (??)
#71 DelHennaPacket("ddS")
#72 AddHennaPacket("ddS")
#73 AddHennaPacket("dSddS")
#74 AddHennasPacket("dSd")
#75 GetCastleListPacket("ddSdSdSddd")
#76 ModifyCharPropertyPacket("ddddddddS")
#77 ModifyCharAbilityDeltaPacket("ddddddddS")
#78 ModifyCharAbilityDeltaPacket("ddddddddS")
#79 DelHenna2Packet("dddS")
#80 AddHenna2Packet("dddS")
#81 AddSkill2Packet("ddddS")
#82 DelSkill2Packet("dddS")
#83 ModifySkill2Packet("ddddS")
#84 AddMacroPacket("dSSSdS")
#85 GetSSQStatusPacket("cdddddddddddd")
#86 GetSSQMainEventRecordPacket("dddddddSd")
#87 ModifyDepositedSSQItemPacket("ddddS")
#88 ChangePetNamePacket("ddSS")
#89 ChangeSubJobPacket("ddS")
#90 StopCharPacket("dd")
#91 CancelPersonalShopPacket("dd")
#92 AddMacroInfoPacket("ddddddSS")
#93 CreateCharacter2Packet("SSddddddddffddddddddddddfS")
#94 AddSkills2Packet("dSd")
#95 AddHennas2Packet("dSd")
#96 AddSubjobsPacket("dSd")
#97 GetPledge2Packet("dS")
#98 DelPledgeEmblemPacket("dS")
#99 RegisterAccountPacket("SS")
#100 DelPledgeAnnouncePacket("dS")
#101 SendPrivateAnnouncePacket("dSS")
#102 GetAgitListPacket("dSdSdSdd")
#103 GetPledgeMemberPacket("dS")
#104 EternalBanPacket("dS")
#105 GetCharacters4Packet("dS")
#106 SetNoblessPacket("ddS")
#107 SetHeroPacket("ddS")
#108 SetPartyLocationPacket("ddddS")
#109 ModOlympiadPointPacket("ddddS")
#110 DummyPacket()

$char_id = 3;
$newname = "KciNicK";

printf("The character %s is %s\n", $char_id, CheckCharacterPacket($char_id) == "x1" ? "online" : "offline");
printf("rename character %s to '%s': %s\n", $char_id, $newname, ChangeCharacterNamePacket($char_id, $newname) == "x1" ? "ok" : "error");

function tounicode($string) {
    $rs = ""; for($i = 0; $i < strlen($string); $i++) $rs .= $string[$i].chr(0);
    return($rs.chr(0).chr(0));
}

function CheckCharacterPacket($p0) {
    $fp = fsockopen("127.0.0.1", "2012", $errno, $errstr, 5); $rs = "x";
    if (!$fp) die("<script>alert('Error connecting to cached: $errstr
[server down??]')</script>");

    $buf = pack("c", 1); // 1 = CheckCharacterPacket();
    $buf .= pack("i", $p0); //char_id

    fwrite($fp, pack("s", (strlen($buf)+2)).$buf);
    $len = unpack("v", fread($fp, 2)); $rid = unpack("c", fread($fp, 1));
    for ($i = 0; $i < (($len[1]-4) / 4); $i++) { $read = unpack("i", fread($fp, 4)); $rs .= $read[1]; }
    fclose($fp); return($rs);
}

function ChangeCharacterNamePacket($p0, $p1) {
    $fp = fsockopen("127.0.0.1", "2012", $errno, $errstr, 5); $rs = "x";
    if (!$fp) die("<script>alert('Error connecting to cached: $errstr
[server down??]')</script>");

    $buf = pack("c", 4); // 4 = ChangeCharacterNamePacket();
    $buf .= pack("i", $p0); //char_id
    $buf .= tounicode($p1); //new char name

    fwrite($fp, pack("s", (strlen($buf)+2)).$buf);
    $len = unpack("v", fread($fp, 2)); $rid = unpack("c", fread($fp, 1));
    for ($i = 0; $i < (($len[1]-4) / 4); $i++) { $read = unpack("i", fread($fp, 4)); $rs .= $read[1]; }
    fclose($fp); return($rs);
}
?>


nucer 12.08.2006 19:08

KciNicK, great thanks!! )))
One more question please...
I have number 1000. 1000 in D it is E8 03 00 00 , right? :)

KciNicK 12.08.2006 21:09

Quote:

Originally Posted by nucer
KciNicK, great thanks!! )))
One more question please...
I have number 1000. 1000 in D it is E8 03 00 00 , right? :)

in little endian, yes...

anyway, the way of writing numbers is cpu arch dependant, first try a simple write(), if that don't work, then start making a function that writes in little endian... but i don't think that u will need one...

Stenly76 12.08.2006 22:38

Not info for AddItemPacket() and small info for AddItem2Packet (function must use Admin ID)
Please, write the example for this packets.
Old method (12; char_id; warehouse; itemType; itemAmount; enchant; eroded; bless; ident; wished) is incorrect

nucer 13.08.2006 15:51

I can't make this functions working :(
CacheD returns no any byte of relpy, just close connection. In CacheD window appears error: admin server closed(127.0.0.1) error: 997

I trying to kick char id 79, packet is:
0B 00 05 4F 00 00 00 7A 00 00 00

Stinker 13.08.2006 18:35

KciNicK, please show yuo "pack" function? thx

Mayii 13.08.2006 19:18

not his function.
http://de.php.net/manual/en/function.pack.php

aralyon 13.08.2006 21:04

Does anyone knows format of a reply from cacheD? First two bytes are packet length, third byte seems to be packet ID, but what about the rest?

nucer 13.08.2006 22:38

Quote:

I can't make this functions working
CacheD returns no any byte of relpy, just close connection. In CacheD window appears error: admin server closed(127.0.0.1) error: 997

I trying to kick char id 79, packet is:
0B 00 05 4F 00 00 00 7A 00 00 00
I am LOL ))
Just incorrect PHP code )
Work fine ))

nucer 13.08.2006 22:42

Quote:

Does anyone knows format of a reply from cacheD? First two bytes are packet length, third byte seems to be packet ID, but what about the rest?
I see it's like in C1.
If you have 1 - all was good.
01, 03, 07 - some errors...

nucer 14.08.2006 01:24

hmm... ADD_ITEM really not work (
CacheD reply is 04...

nucer 14.08.2006 01:32

AddItem format is DDDDDDDDDDD, right?

Error codes from C1 cacheD:

Code:

01=SOCKET_INT_ERROR
2=SOCKET_INT_ARGS_NEED
3=SOCKET_INT_ARGS_INVALID
4=SOCKET_INT_CHAR_NOT_FOUNT
5=SOCKET_INT_WAREHOUSE_NOT_FOUNT
6=SOCKET_INT_ACCOUNT_NOT_FOUND
7=SOCKET_INT_CHAR_LOGIN
8=SOCKET_INT_TOO_MANY_CHARS
9=SOCKET_INT_CHAR_INPLEDGE
010=SOCKET_INT_CHAR_PLEDGEOWNER
011=SOCKET_INT_CANNOT_BAN
012=SOCKET_INT_NAME_EXISTS
013=SOCKET_INT_OBSOLETE
014=SOCKET_INT_INVALID_CHARNAME
015=SOCKET_INT_CHAR_NOT_LOGIN
016=SOCKET_INT_SAME_CHAR
017=SOCKET_INT_CHAR_NOTPLEDGE
018=SOCKET_INT_CHAR_PLEDGEMASTER
019=SOCKET_INT_SVR_NOTCONNECTED
020=SOCKET_INT_CREATE_PET_FAIL
021=SOCKET_INT_PLEDGE_EXISTS
022=SOCKET_INT_NO_CHARS
023=SOCKET_INT_INVALID_ANNOUNCEID
024=SOCKET_INT_PLEDGE_NOT_FOUND
025=SOCKET_INT_CASTLE_NOT_FOUND
026=SOCKET_INT_PET_NOT_FOUND


testdude 14.08.2006 03:42

additem function has been replaced with AddItem2, cos additem was char name, additem2 is char id, and all functions now use char id instead...

scott 14.08.2006 10:28

AddItem2 work?
I have 01 in cached reply, but no have items in inventory.

nucer 14.08.2006 12:08

Quote:

AddItem2 work?
I have 01 in cached reply, but no have items in inventory.
You need to insert itemdata in CacheD :)

scott 14.08.2006 12:28

2nucer
tnx :)

nucer 14.08.2006 12:45

And AddItem2 format is DDDDDDDDDS
S - any string with not null length, i don't know who what is it )

scott 14.08.2006 13:56

$buf = pack("c", 55); // 55 = AddItem2Packet();
$buf .= pack("i", 3652); //char_id
$buf .= pack("i", 0); //warehouse
$buf .= pack("i", 57); //item_type
$buf .= pack("i", 1000); //item_amount
$buf .= pack("i", 0); //enchant ?
$buf .= pack("i", 0); //??
$buf .= pack("i", 0); //??
$buf .= pack("i", 0); //??
$buf .= pack("i", 0); //??
$buf .= tounicode("Web1"); //who
Its write?
Items added in tables.
Cacned returns 1, but no item.

Stinker 15.08.2006 09:50

nucer you can use AddItem2Packet?
help please

Stinker 15.08.2006 14:13

thx all

KciNicK 15.08.2006 17:06

the last S is the name of the admin that do the request, intended for use with l2admin, is the name of the admin logued on that panel... is not needed...

Stinker 15.08.2006 17:47

right

KciNicK 15.08.2006 18:59

// EDIT //
AddItem2(char_id, ware=1 or char=0, item_id, amount, enchants, eroded, bless, ident, wished, 1);

u need a "1" at the end...

scott 18.08.2006 07:24

Not work.
Anybody can help?

KciNicK 18.08.2006 15:08

Quote:

Originally Posted by scott (Post 65051)
Not work.
Anybody can help?

it works for me...

testdude 18.08.2006 15:39

for AddItem the admin id IS needed, it errors otherwise, though for me it refused to work so i hexed the cached to work without admin id xD
$pack=pack("cVVVVVVVVVVV",55,$charid,0,$itemid,$am ount,$enchant,0,0,0,0,0,0);
$out=pack("s",strlen($pack)+2);
$out.=$pack;
^ thats what i did for additem, and before anyone points out that im using V instead of "i", its because "i" is machine dependant, V is 32bit, and i run this on a 64bit server...

scrap512 18.08.2006 17:54

so anyone can run these commands from anywhere .. isn't that a bit unsafe?

testdude 18.08.2006 17:57

thats what firewalls are for

Kenjiro 20.08.2006 12:46

Quote:

Originally Posted by KciNicK (Post 64926)
// EDIT //
AddItem2(char_id, ware=1 or char=0, item_id, amount, enchants, eroded, bless, ident, wished, 1);

u need a "1" at the end...

Why is that 1 at the end? Are another commands used like that (with addidional 1)?

P.S. If You could explain me why i have error in system logs:
08/20/2006 14:47:xx.xx4, admin server closed(127.0.0.1) error: 997
when command has been executed correctly ?

P.P.S. Sometimes i have:
08/20/2006 14:38:xx.xx5, admin server closed(127.0.0.1) error: 258
Weird... very weird...

testdude 20.08.2006 14:50

the 1 at the end is the "admin id", also i would like to point out, that error when the socket closes is not an error to do with the function itself, it is just the response from WSAGetLastError()

Kenjiro 20.08.2006 16:40

Thanks a lot!

Kenjiro 21.08.2006 15:02

I have another problem, highest item_type (item id from itemdata) which can be added to database is 7838, everything above it results -> "01". Item is added to database (via 'load items' cached option), but... can not add...
What is weird, that i can add items which are not in database (not in itemcache.txt & loaded), but with item_type <= 7838.

I'm stupid, You know... full cached restart (quit & run) has solved problem... (to be remembered: before asking, try to restart ;))

AgeNT2005 30.08.2006 15:59

Say if you please id function for Cached for the changes of subjob0_class and deleted all skill
I use translator, sorry.

barabashka 01.09.2006 14:49

Quote:

Originally Posted by AgeNT2005 (Post 66075)
Say if you please id function for Cached for the changes of subjob0_class and deleted all skill
I use translator, sorry.

So, I think you need to know structure of special Cashed Function for changing player profession. Couse, in lin2world>userdata there two rows class and sub_job0. And this two parameters are coordinating player profession. But cashed scripts for changing player's classes are working not correctly. If someone know or understand this problem - plz PM me. Together, we can solve this problem.

Haygor 02.09.2006 01:30

Quote:

Originally Posted by Kenjiro (Post 65387)
I have another problem, highest item_type (item id from itemdata) which can be added to database is 7838, everything above it results -> "01". Item is added to database (via 'load items' cached option), but... can not add...
What is weird, that i can add items which are not in database (not in itemcache.txt & loaded), but with item_type <= 7838.

I'm stupid, You know... full cached restart (quit & run) has solved problem... (to be remembered: before asking, try to restart ;))

I have this exact same problem, I know for a fact the items are added to the table, pllus I have restarted cached several times, but still receiving a code 01 (item not in ItemData table). Any other ideas?


All times are GMT. The time now is 23:54.