Write log to a file using Sipp - voip

How could write log to a file using Sipp, and How could I know every call return status,
I only want to kown every call return response status, for example 200 ..

Just run sipp and see params:
-trace_msg : Displays sent and received SIP messages in <scenario file
name>_<pid>_messages.log
-trace_shortmsg : Displays sent and received SIP messages as CSV in
<scenario file name>_<pid>_shortmessages.log

Related

why my node.js discord.js bot is not sending files? (no errors) (can send messages)

So, I built a discord.js/node.js bot. and added a command '$t getmsg'
what I have tried:
sending a single file
sending two files
checking the permission
what the bot should do:
send the message + files
what it does:
sends the text only
I got no error in the CMD
the pice of code that should send the file:
message.channel.send("ALL SAVED MESSAGES. if you can't see any files, I don't have permission to upload.", {
files: [
"./messages/savedmessages.txt",
"./messages/messages.txt"
]
});
channel.send only takes a maximum of one argument, if you have multiple, as you do, you must pass them all as an object. That is to say you must add your message to the object like so:
message.channel.send({
content: "ALL SAVED MESSAGES. if you can't see any files, I don't have permission to upload.",
files: [
"./messages/savedmessages.txt",
"./messages/messages.txt"
]
});

Python Client Rest API Invocation - Invalid character found in method name [{}POST]. HTTP method names must be tokens

Client
Python Version - 3.9,
Python Requests module version - 2.25
Server
Java 13,
Tomcat 9.
I have a Tomcat+Java based server exposing REST APIs. I am writing a client in python to consume those APIs. Everything is fine until I send empty body in POST request. It is a valid use case for us. If I send empty body I get 400 bad request error - Invalid character found in method name [{}POST]. HTTP method names must be tokens. If I send empty request from POSTMAN or Java or CURL it works fine, problem is only when I used python as a client.
Following is python snippet -
json_object={}
header = {'alias': 'A', 'Content-Type' : 'application/json', 'Content-Length' : '0'}
resp = requests.post(url, auth=(username, password), headers=header, json=json_object)
I tried using data as well instead of json param to send payload with not much of success.
I captured the wireshark dumps to undertand it further and found that, the request tomcat received is not as per RFC2616 (https://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html). Especially the part -
Request-Line = Method SP Request-URI SP HTTP-Version CRLF
Because I could see in from wireshark dumps it looked like - {}POST MY-APP-URI HTTP/1.1
As we can see the empty body is getting prefixed with http-method, hence tomcat reports that as an error.
I then looked at python http library code -client.py. Following are relevant details -
File - client.py
Method - _send_output (starting at line # 1001) - It first sends the header at line #1010 and then the body somewhere down in the code. I thought(I could be wrong here) perhaps in this case header is way longer 310 bytes than body 2 bytes, so by the time complete header is sent on wire body is pushed and hence TCP frames are order in such a way that body appears first. To corroborate this I added a delay of 1 second just after sending header line#1011 and bingo, the error disappeared and it started working fine. Not sure if this is completely correct analysis, but can someone in the know can confirm or let me know how to fix this.

How to change the payload of a packet on retransmission?

I want to try to implement the RSTEG method using scapy. That is, send a packet, the receiver does not send a confirmation message, this packet is sent again, but with a steganogram in the payload, the receiver again does not send a confirmation message. Then this package is sent again, but without the steganogram. (the same packet is sent three times, but a steganogram is sent a second time.) Is it possible to implement it with Scapy, How can I do that?
With the creation of packets and they are sent there is no problem. I can use timeout and retry to not receive the confirmation message and resend the package. But I do not understand how in this case to change the payload and at the end to get a confirmation message.
You can do something like -
packet=IP() / UDP() / ... / Raw(load=your_data) # the ... are for all your other protocols
response=sr1(packet, timeout=5)
if response is None:
# response is not received, send it 2nd time
packet[Raw].load = your_data_with_steganogram
response=sr1(packet, timeout=1)
if response is None:
# response is not received, send it 3rd time
packet[Raw].load = your_data
response=sr1(packet, timeout=1)

Node.js (sails.js) Find total number of files sent in a file upload

I have a file upload system in sails.js app. I want to process the uploads before saving them in the server. My form on the client side allows multiple file uploads. Now on the server side how do I know how many files were sent?
For example I can find the total bytes to be expected from the upload using the following:
req._fileparser.form.bytesExpected
However, I couldn't find something similar that helps me find the total number of files sent to the server.
Also the above code req._fileparser.form.bytesExpected, is there a better way to get total combined file size of the files sent through the upload form by the client?
In the github repository for Skipper there is a file: index.js
Line 92 from the above file, which appears to deal with multipart file uploads, contains the following:
var hasUpstreams = req._fileparser && req._fileparser.upstreams.length;
You should check the length of upstreams in your code, and see if that contains the number of files you sent.
Another option: send a parameter in your request from the client with the number of files uploaded.
See the skipper ReadMe section about Text Parameters.
Skipper allows you to access the other non-file metadata parameters (e.g "photoCaption" or
"commentId") in the conventional way. That includes url/JSON-encoded HTTP body parameters
(req.body), querystring parameters (req.query), or "route" parameters (req.params); in other words,
all the standard stuff sent in standard AJAX uploads or HTML form submissions. And helper methods
like req.param() and req.allParams() work too.
I've just found a previous question/answer on stackoverflow.
You might try using var upload = req.file('file')._files[0].stream to access and validate, as shown in the above answer.

Is socket.write thread" safe?

I am using node.js to communicate over a socket in json. One of the operations sends a big file over the socket in base64 format. As a result the message is split into packets and triggers various data events on the client. I handle this using a buffer on the client side
var response={
file: fs.readFileSync("FileName","base64")
}
socket.write(JSON.stringify(response));
On the client side, using a buffer
cleartextStream.on("data",function(data){
console.log("Received data")
try {
data=JSON.parse(data);
_buffer="";
events.trigger(data.event,data);
}
catch(e){
console.log("Incomplete message received. Building Buffer");
_buffer+=data;
if(/\}$/.test(data) ){//Tests for json boundary
data=JSON.parse(_buffer);
events.trigger(data.event,data);
}
}
This works fine for me for now. The only problem I anticipate is if while the file is being sent, some other event triggers a write on the socket.
t=0 Start sending file
t=5 Still sending file
t=6 Another event uses socket.write to start sending message
t=7 still sending file
t=8 Another event sending message
This will result in garbled messages. So does socket.write block while sending a single message, or will it allow other methods to use socket.write even before the transmission is completed?

Resources