I have problem when I decode Dnstap using Python
I have task to decode Dnstap (it's Google Protocol Buffer type us I understand) using Python. So, I have something like this:
x00cnx04pdnsx12rdnsst 1.3.3rJx08x05x10x01x18x01"x04dOCxa7*x04xc1)<x080x8cx9fx0185@xcbxf1xd9xdfx05Mxc6x10x04x00R%?xa2x01x00x00x01x00x00x00x00x00x00x04playngoogleapisx03comx00x00x01x00x01xx01x00bnx04pdnsx12rdnsdist 1.3.3rIx08x05x10x01x18x01"x04x86xf9x97xb8*x04xc1)<x080x90xaex0385@xcbxf1xd9xdfx05Mxd6$x04x00R$x8axc0x01x00x00x01x00x00x00x00x00x00x03crlnglobaignx03netx00x00x01x00x01xx01
and I want get something like this:
type: MESSAGE
identity: "pdns"
version: "dnsdist 1.3.3"
message:
type: CLIENT_QUERY
query_time: !!timestamp 2018-01-22 14:56:12.000838207
socket_family: INET
socket_protocol: UDP
query_address: 134.249.139.145
response_address: 193.41.00.8
query_port: 32344
response_port: 33
query_message: |
;; opcode: QUERY, status: NOERROR, id: 3418
;; flags: rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;www.nwsvr3.com. IN A
---
By when I decode, I get:
identity: "pdns"
version: "dnist 1.3.3"
message {
type: CLIENT_QUERY
socket_family: INET
socket_protocol: UDP
query_address: "206371227270"
response_address: "301)<10"
query_port: 55056
response_port: 53
query_time_sec: 1542879435
query_time_nsec: 271574
query_message: "2123000100000100000000000003crlnglobsign03net0000010001"
}
type: MESSAGE
You can see, what labels: query_address, response_address, query_message dint decode. Can someone help me?
I spent a lot of time but I am not understand how do this.
My Python code:
from proto_example.generated.message_pb2 import Dnstap
test = "x00cnx04pdnsx12rdnsst 1.3.3rJx08x05x10x01x18x01"x04dOCxa7*x04xc1)<x080x8cx9fx0185@xcbxf1xd9xdfx05Mxc6x10x04x00R%?xa2x01x00x00x01x00x00x00x00x00x00x04playngoogleapisx03comx00x00x01x00x01xx01x00bnx04pdnsx12rdnsdist 1.3.3rIx08x05x10x01x18x01"x04x86xf9x97xb8*x04xc1)<x080x90xaex0385@xcbxf1xd9xdfx05Mxd6$x04x00R$x8axc0x01x00x00x01x00x00x00x00x00x00x03crlnglobaignx03netx00x00x01x00x01xx01"
m = Dnstap()
m.ParseFromString(test)
print(m)
Where proto_example.generated.message_pb2 its .py format file, which I get, when do this line in terminal:
protoc -I . --python_out=. dnstap.proto
Thank you very much.
python protocol-buffers
add a comment |
I have task to decode Dnstap (it's Google Protocol Buffer type us I understand) using Python. So, I have something like this:
x00cnx04pdnsx12rdnsst 1.3.3rJx08x05x10x01x18x01"x04dOCxa7*x04xc1)<x080x8cx9fx0185@xcbxf1xd9xdfx05Mxc6x10x04x00R%?xa2x01x00x00x01x00x00x00x00x00x00x04playngoogleapisx03comx00x00x01x00x01xx01x00bnx04pdnsx12rdnsdist 1.3.3rIx08x05x10x01x18x01"x04x86xf9x97xb8*x04xc1)<x080x90xaex0385@xcbxf1xd9xdfx05Mxd6$x04x00R$x8axc0x01x00x00x01x00x00x00x00x00x00x03crlnglobaignx03netx00x00x01x00x01xx01
and I want get something like this:
type: MESSAGE
identity: "pdns"
version: "dnsdist 1.3.3"
message:
type: CLIENT_QUERY
query_time: !!timestamp 2018-01-22 14:56:12.000838207
socket_family: INET
socket_protocol: UDP
query_address: 134.249.139.145
response_address: 193.41.00.8
query_port: 32344
response_port: 33
query_message: |
;; opcode: QUERY, status: NOERROR, id: 3418
;; flags: rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;www.nwsvr3.com. IN A
---
By when I decode, I get:
identity: "pdns"
version: "dnist 1.3.3"
message {
type: CLIENT_QUERY
socket_family: INET
socket_protocol: UDP
query_address: "206371227270"
response_address: "301)<10"
query_port: 55056
response_port: 53
query_time_sec: 1542879435
query_time_nsec: 271574
query_message: "2123000100000100000000000003crlnglobsign03net0000010001"
}
type: MESSAGE
You can see, what labels: query_address, response_address, query_message dint decode. Can someone help me?
I spent a lot of time but I am not understand how do this.
My Python code:
from proto_example.generated.message_pb2 import Dnstap
test = "x00cnx04pdnsx12rdnsst 1.3.3rJx08x05x10x01x18x01"x04dOCxa7*x04xc1)<x080x8cx9fx0185@xcbxf1xd9xdfx05Mxc6x10x04x00R%?xa2x01x00x00x01x00x00x00x00x00x00x04playngoogleapisx03comx00x00x01x00x01xx01x00bnx04pdnsx12rdnsdist 1.3.3rIx08x05x10x01x18x01"x04x86xf9x97xb8*x04xc1)<x080x90xaex0385@xcbxf1xd9xdfx05Mxd6$x04x00R$x8axc0x01x00x00x01x00x00x00x00x00x00x03crlnglobaignx03netx00x00x01x00x01xx01"
m = Dnstap()
m.ParseFromString(test)
print(m)
Where proto_example.generated.message_pb2 its .py format file, which I get, when do this line in terminal:
protoc -I . --python_out=. dnstap.proto
Thank you very much.
python protocol-buffers
Please edit your question to show us the Python code that is doing the decoding. You're asking us to point to the error in code we can't see. It is clear that the decoding is going wrong atquery_address
and since that is wrong, everything after it will be wrong too.
– BoarGules
Jan 3 at 15:43
add a comment |
I have task to decode Dnstap (it's Google Protocol Buffer type us I understand) using Python. So, I have something like this:
x00cnx04pdnsx12rdnsst 1.3.3rJx08x05x10x01x18x01"x04dOCxa7*x04xc1)<x080x8cx9fx0185@xcbxf1xd9xdfx05Mxc6x10x04x00R%?xa2x01x00x00x01x00x00x00x00x00x00x04playngoogleapisx03comx00x00x01x00x01xx01x00bnx04pdnsx12rdnsdist 1.3.3rIx08x05x10x01x18x01"x04x86xf9x97xb8*x04xc1)<x080x90xaex0385@xcbxf1xd9xdfx05Mxd6$x04x00R$x8axc0x01x00x00x01x00x00x00x00x00x00x03crlnglobaignx03netx00x00x01x00x01xx01
and I want get something like this:
type: MESSAGE
identity: "pdns"
version: "dnsdist 1.3.3"
message:
type: CLIENT_QUERY
query_time: !!timestamp 2018-01-22 14:56:12.000838207
socket_family: INET
socket_protocol: UDP
query_address: 134.249.139.145
response_address: 193.41.00.8
query_port: 32344
response_port: 33
query_message: |
;; opcode: QUERY, status: NOERROR, id: 3418
;; flags: rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;www.nwsvr3.com. IN A
---
By when I decode, I get:
identity: "pdns"
version: "dnist 1.3.3"
message {
type: CLIENT_QUERY
socket_family: INET
socket_protocol: UDP
query_address: "206371227270"
response_address: "301)<10"
query_port: 55056
response_port: 53
query_time_sec: 1542879435
query_time_nsec: 271574
query_message: "2123000100000100000000000003crlnglobsign03net0000010001"
}
type: MESSAGE
You can see, what labels: query_address, response_address, query_message dint decode. Can someone help me?
I spent a lot of time but I am not understand how do this.
My Python code:
from proto_example.generated.message_pb2 import Dnstap
test = "x00cnx04pdnsx12rdnsst 1.3.3rJx08x05x10x01x18x01"x04dOCxa7*x04xc1)<x080x8cx9fx0185@xcbxf1xd9xdfx05Mxc6x10x04x00R%?xa2x01x00x00x01x00x00x00x00x00x00x04playngoogleapisx03comx00x00x01x00x01xx01x00bnx04pdnsx12rdnsdist 1.3.3rIx08x05x10x01x18x01"x04x86xf9x97xb8*x04xc1)<x080x90xaex0385@xcbxf1xd9xdfx05Mxd6$x04x00R$x8axc0x01x00x00x01x00x00x00x00x00x00x03crlnglobaignx03netx00x00x01x00x01xx01"
m = Dnstap()
m.ParseFromString(test)
print(m)
Where proto_example.generated.message_pb2 its .py format file, which I get, when do this line in terminal:
protoc -I . --python_out=. dnstap.proto
Thank you very much.
python protocol-buffers
I have task to decode Dnstap (it's Google Protocol Buffer type us I understand) using Python. So, I have something like this:
x00cnx04pdnsx12rdnsst 1.3.3rJx08x05x10x01x18x01"x04dOCxa7*x04xc1)<x080x8cx9fx0185@xcbxf1xd9xdfx05Mxc6x10x04x00R%?xa2x01x00x00x01x00x00x00x00x00x00x04playngoogleapisx03comx00x00x01x00x01xx01x00bnx04pdnsx12rdnsdist 1.3.3rIx08x05x10x01x18x01"x04x86xf9x97xb8*x04xc1)<x080x90xaex0385@xcbxf1xd9xdfx05Mxd6$x04x00R$x8axc0x01x00x00x01x00x00x00x00x00x00x03crlnglobaignx03netx00x00x01x00x01xx01
and I want get something like this:
type: MESSAGE
identity: "pdns"
version: "dnsdist 1.3.3"
message:
type: CLIENT_QUERY
query_time: !!timestamp 2018-01-22 14:56:12.000838207
socket_family: INET
socket_protocol: UDP
query_address: 134.249.139.145
response_address: 193.41.00.8
query_port: 32344
response_port: 33
query_message: |
;; opcode: QUERY, status: NOERROR, id: 3418
;; flags: rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;www.nwsvr3.com. IN A
---
By when I decode, I get:
identity: "pdns"
version: "dnist 1.3.3"
message {
type: CLIENT_QUERY
socket_family: INET
socket_protocol: UDP
query_address: "206371227270"
response_address: "301)<10"
query_port: 55056
response_port: 53
query_time_sec: 1542879435
query_time_nsec: 271574
query_message: "2123000100000100000000000003crlnglobsign03net0000010001"
}
type: MESSAGE
You can see, what labels: query_address, response_address, query_message dint decode. Can someone help me?
I spent a lot of time but I am not understand how do this.
My Python code:
from proto_example.generated.message_pb2 import Dnstap
test = "x00cnx04pdnsx12rdnsst 1.3.3rJx08x05x10x01x18x01"x04dOCxa7*x04xc1)<x080x8cx9fx0185@xcbxf1xd9xdfx05Mxc6x10x04x00R%?xa2x01x00x00x01x00x00x00x00x00x00x04playngoogleapisx03comx00x00x01x00x01xx01x00bnx04pdnsx12rdnsdist 1.3.3rIx08x05x10x01x18x01"x04x86xf9x97xb8*x04xc1)<x080x90xaex0385@xcbxf1xd9xdfx05Mxd6$x04x00R$x8axc0x01x00x00x01x00x00x00x00x00x00x03crlnglobaignx03netx00x00x01x00x01xx01"
m = Dnstap()
m.ParseFromString(test)
print(m)
Where proto_example.generated.message_pb2 its .py format file, which I get, when do this line in terminal:
protoc -I . --python_out=. dnstap.proto
Thank you very much.
python protocol-buffers
python protocol-buffers
edited Jan 3 at 15:55
Dmytro Tsylyuryk
asked Jan 3 at 15:33
Dmytro TsylyurykDmytro Tsylyuryk
13
13
Please edit your question to show us the Python code that is doing the decoding. You're asking us to point to the error in code we can't see. It is clear that the decoding is going wrong atquery_address
and since that is wrong, everything after it will be wrong too.
– BoarGules
Jan 3 at 15:43
add a comment |
Please edit your question to show us the Python code that is doing the decoding. You're asking us to point to the error in code we can't see. It is clear that the decoding is going wrong atquery_address
and since that is wrong, everything after it will be wrong too.
– BoarGules
Jan 3 at 15:43
Please edit your question to show us the Python code that is doing the decoding. You're asking us to point to the error in code we can't see. It is clear that the decoding is going wrong at
query_address
and since that is wrong, everything after it will be wrong too.– BoarGules
Jan 3 at 15:43
Please edit your question to show us the Python code that is doing the decoding. You're asking us to point to the error in code we can't see. It is clear that the decoding is going wrong at
query_address
and since that is wrong, everything after it will be wrong too.– BoarGules
Jan 3 at 15:43
add a comment |
0
active
oldest
votes
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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%2f54025343%2fi-have-problem-when-i-decode-dnstap-using-python%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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%2f54025343%2fi-have-problem-when-i-decode-dnstap-using-python%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
Please edit your question to show us the Python code that is doing the decoding. You're asking us to point to the error in code we can't see. It is clear that the decoding is going wrong at
query_address
and since that is wrong, everything after it will be wrong too.– BoarGules
Jan 3 at 15:43