scapy - fields_desc - add field as offset
up vote
0
down vote
favorite
I'm trying to describe a field as an offset and access it's data
For example:
fields_desc = [LEShortField("structure_size",0),
ByteField("flags",0),
**LEShortField("blob_offset",0)**,
LEFieldLenField("user_name_length", 0),
LEShortField("user_name_maxlength", 0),
**LEIntField("user_name_offset", 0)**]
I need to take the variable blob_offset and add it user_name_offset in order to extract the user name.
How can I do it ?? I didn't find and special variable for it...
Thanks
python networking scapy
add a comment |
up vote
0
down vote
favorite
I'm trying to describe a field as an offset and access it's data
For example:
fields_desc = [LEShortField("structure_size",0),
ByteField("flags",0),
**LEShortField("blob_offset",0)**,
LEFieldLenField("user_name_length", 0),
LEShortField("user_name_maxlength", 0),
**LEIntField("user_name_offset", 0)**]
I need to take the variable blob_offset and add it user_name_offset in order to extract the user name.
How can I do it ?? I didn't find and special variable for it...
Thanks
python networking scapy
what do you want your packet to look like in the end? do you wantuser_nameto also be a field? do you plan on parsing the entire "blob"?
– AntiMatterDynamite
16 hours ago
yes. I need the user_name as a field. I just don't know where to insert it because it depends on a specific offset...Is it possible?
– 1337
16 hours ago
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm trying to describe a field as an offset and access it's data
For example:
fields_desc = [LEShortField("structure_size",0),
ByteField("flags",0),
**LEShortField("blob_offset",0)**,
LEFieldLenField("user_name_length", 0),
LEShortField("user_name_maxlength", 0),
**LEIntField("user_name_offset", 0)**]
I need to take the variable blob_offset and add it user_name_offset in order to extract the user name.
How can I do it ?? I didn't find and special variable for it...
Thanks
python networking scapy
I'm trying to describe a field as an offset and access it's data
For example:
fields_desc = [LEShortField("structure_size",0),
ByteField("flags",0),
**LEShortField("blob_offset",0)**,
LEFieldLenField("user_name_length", 0),
LEShortField("user_name_maxlength", 0),
**LEIntField("user_name_offset", 0)**]
I need to take the variable blob_offset and add it user_name_offset in order to extract the user name.
How can I do it ?? I didn't find and special variable for it...
Thanks
python networking scapy
python networking scapy
asked 17 hours ago
1337
778
778
what do you want your packet to look like in the end? do you wantuser_nameto also be a field? do you plan on parsing the entire "blob"?
– AntiMatterDynamite
16 hours ago
yes. I need the user_name as a field. I just don't know where to insert it because it depends on a specific offset...Is it possible?
– 1337
16 hours ago
add a comment |
what do you want your packet to look like in the end? do you wantuser_nameto also be a field? do you plan on parsing the entire "blob"?
– AntiMatterDynamite
16 hours ago
yes. I need the user_name as a field. I just don't know where to insert it because it depends on a specific offset...Is it possible?
– 1337
16 hours ago
what do you want your packet to look like in the end? do you want
user_name to also be a field? do you plan on parsing the entire "blob"?– AntiMatterDynamite
16 hours ago
what do you want your packet to look like in the end? do you want
user_name to also be a field? do you plan on parsing the entire "blob"?– AntiMatterDynamite
16 hours ago
yes. I need the user_name as a field. I just don't know where to insert it because it depends on a specific offset...Is it possible?
– 1337
16 hours ago
yes. I need the user_name as a field. I just don't know where to insert it because it depends on a specific offset...Is it possible?
– 1337
16 hours ago
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
well you don't exactly say how your packet looks, assuming your "blob" and username are right after the packet you already specified you can try to do something like this:
fields_desc = [LEShortField("structure_size",0),
ByteField("flags",0),
LEFieldLenField("blob_offset",0, length_of="blob_offset_pad", fmt="!H"),
LEFieldLenField("user_name_length", 0, length_of="user_name"),
LEShortField("user_name_maxlength", 0),
LEFieldLenField("user_name_offset", 0, length_of="user_name", fmt="!I"),
StrFixedLenField("blob_offset_pad", 0, length_from = lambda pkt: pkt.blob_offset),
StrFixedLenField("user_name_offset_pad", 0, length_from = lambda pkt: pkt.user_name_offset),
StrFixedLenField("user_name", "", length_from= lambda pkt: pkt.user_name_length)]
again can't really test this because you didn't provide any useful examples
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
well you don't exactly say how your packet looks, assuming your "blob" and username are right after the packet you already specified you can try to do something like this:
fields_desc = [LEShortField("structure_size",0),
ByteField("flags",0),
LEFieldLenField("blob_offset",0, length_of="blob_offset_pad", fmt="!H"),
LEFieldLenField("user_name_length", 0, length_of="user_name"),
LEShortField("user_name_maxlength", 0),
LEFieldLenField("user_name_offset", 0, length_of="user_name", fmt="!I"),
StrFixedLenField("blob_offset_pad", 0, length_from = lambda pkt: pkt.blob_offset),
StrFixedLenField("user_name_offset_pad", 0, length_from = lambda pkt: pkt.user_name_offset),
StrFixedLenField("user_name", "", length_from= lambda pkt: pkt.user_name_length)]
again can't really test this because you didn't provide any useful examples
add a comment |
up vote
0
down vote
well you don't exactly say how your packet looks, assuming your "blob" and username are right after the packet you already specified you can try to do something like this:
fields_desc = [LEShortField("structure_size",0),
ByteField("flags",0),
LEFieldLenField("blob_offset",0, length_of="blob_offset_pad", fmt="!H"),
LEFieldLenField("user_name_length", 0, length_of="user_name"),
LEShortField("user_name_maxlength", 0),
LEFieldLenField("user_name_offset", 0, length_of="user_name", fmt="!I"),
StrFixedLenField("blob_offset_pad", 0, length_from = lambda pkt: pkt.blob_offset),
StrFixedLenField("user_name_offset_pad", 0, length_from = lambda pkt: pkt.user_name_offset),
StrFixedLenField("user_name", "", length_from= lambda pkt: pkt.user_name_length)]
again can't really test this because you didn't provide any useful examples
add a comment |
up vote
0
down vote
up vote
0
down vote
well you don't exactly say how your packet looks, assuming your "blob" and username are right after the packet you already specified you can try to do something like this:
fields_desc = [LEShortField("structure_size",0),
ByteField("flags",0),
LEFieldLenField("blob_offset",0, length_of="blob_offset_pad", fmt="!H"),
LEFieldLenField("user_name_length", 0, length_of="user_name"),
LEShortField("user_name_maxlength", 0),
LEFieldLenField("user_name_offset", 0, length_of="user_name", fmt="!I"),
StrFixedLenField("blob_offset_pad", 0, length_from = lambda pkt: pkt.blob_offset),
StrFixedLenField("user_name_offset_pad", 0, length_from = lambda pkt: pkt.user_name_offset),
StrFixedLenField("user_name", "", length_from= lambda pkt: pkt.user_name_length)]
again can't really test this because you didn't provide any useful examples
well you don't exactly say how your packet looks, assuming your "blob" and username are right after the packet you already specified you can try to do something like this:
fields_desc = [LEShortField("structure_size",0),
ByteField("flags",0),
LEFieldLenField("blob_offset",0, length_of="blob_offset_pad", fmt="!H"),
LEFieldLenField("user_name_length", 0, length_of="user_name"),
LEShortField("user_name_maxlength", 0),
LEFieldLenField("user_name_offset", 0, length_of="user_name", fmt="!I"),
StrFixedLenField("blob_offset_pad", 0, length_from = lambda pkt: pkt.blob_offset),
StrFixedLenField("user_name_offset_pad", 0, length_from = lambda pkt: pkt.user_name_offset),
StrFixedLenField("user_name", "", length_from= lambda pkt: pkt.user_name_length)]
again can't really test this because you didn't provide any useful examples
answered 14 hours ago
AntiMatterDynamite
828212
828212
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53371195%2fscapy-fields-desc-add-field-as-offset%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
what do you want your packet to look like in the end? do you want
user_nameto also be a field? do you plan on parsing the entire "blob"?– AntiMatterDynamite
16 hours ago
yes. I need the user_name as a field. I just don't know where to insert it because it depends on a specific offset...Is it possible?
– 1337
16 hours ago