ZMQ HTTP Server - empty Request - c

While reading on ZMQ, I encountered this link - A Web Server in 30 Lines of C. Highly motivated, I tried running the code and it does indeed print "Hello, World!"
Here's the problem: I never quite get the puts (request); to print anything. Essentially, I was looking for being able to send back some data based on query parrams. Example: http://localhost:8080/hello?myname=mho
response would change with sprintf of the name.
I believe I am not completely able to understand the code (:( just 30 lines!).
Any useful links on how the CZMQ is handling the frames? I am not sure, I am able to make good sense out of the inline documentation in the headers.
Any pointers? Happy to read through please.
Am I missing something obvious here?

I agree it's pretty neat, but it's not an HTTP server - it doesn't understand anything about HTTP, especially not how to parse a query string.
You can certainly use 0MQ to send messages very simply. The zguide has examples of many patterns in many languages - should be everything you need. You need to write both a client and server (really a sender and a receiver) to send anything meaningful over 0MQ. If you're hoping to use a generic http client like curl or wget, then use a real HTTP server instead of 0MQ. Many scripting languages let you launch an HTTP listener in a single line of code. Choose what best fits your needs. If you do use 0MQ, there is an IRC channel on Freenode where you can get help.

Related

Pass value to C binary through cURL (or FTP)

I've got a web application that I know to be written in C, that's running on a specified IP address and port. I can access the application either with telnet or nc. With each of those, once connecting I'm prompted for input.
Since I've got a copy of the binary, running it through strings and hd showed me that the application is looking for a particular string to validate.
There's a file sitting on that domain that I'd like to access, which I can't seem to do with telnet or nc, so I'm thinking that either cURL or ftp would be the better bet here.
However, since the string validation that happens with this running service isn't really a password, I'm not sure how to pass this string value into the service with cURL or ftp. My gut tells me that I probably need to structure the command as a POST, but since this definitely isn't an HTTP service, I'm not sure how to proceed.
Any ideas?
(not an answer, but too long to post as a comment)
when dealing with undocumented custom protocols, telnet/curl/wget is definitely not suitable, and nc is not practical. write your own client.
you say the server is expecting a string? well, maybe you could run a dictionary attack on it, make a client that tries everything in a large dictionary (like this?), looking for any non-standard response, and go from there. add any strings you find in the binary too, ofc
if that gets you nowhere, maybe the binary is vulnerable to timing attacks? maybe you can extract a string that it is looking for, through a timing attack
and because you already have the binary, you could run it through a disassembler and study the assembly code, it should reveal both whether or not it's timing-attack vulnerable, and, if the strings are hardcoded, what string it is looking for, albeit, reading compiled assembly code is really difficult.. (game crackers does this all the time for cracking video game copy protections)

Alexa skill in java not waiting for response

I'm trying the WiseGuy sample app in Java and can get Alexa to say "knock knock" but then the light turns off and that's it, I don't get to say "who's there".
Same issue with my own skill, even though I'm using newAskResponse(). Is there anything else I need to do?
Thanks!
Etienne
Fixed it by using the jar file produced by Maven instead of directly using the source code. Not sure why that makes a difference.
When you face issues like this, don't forget, you can use the skill configuration "Test" tab, to test the skill, to make sure it's not an interpretation problem (which can happen often).
Also, if doing that still gives you a response that you are not expecting you can copy that intent request:
And that past it on your lambda function event Test, there you will be able to see a more detail "debug" and if you are still not sure, make sure you do a few prints to at least pin point where the issue is:)

Using Curl To Send Info

I have to use the Curl library to send a string to a morse code translator.(http://mattfedder.com/cgi-bin/morse.pl)
Then I have to take back the result and extract the translated code.
My prof didn't explain curl very well at all and I cannot find any clear examples.
I am not by any means asking for people to code it I just need sources to examples that may help. I apologize if these are blatantly easy to find I have put time into a search just none seemed relevant.
Curl works with webpages/webservices etc.
Its library you can use to interact with web apps without writing all the code.
read this page.
http://curl.haxx.se/libcurl/c/libcurl-tutorial.html
(could not comment as i dont have 50 rep sorry)

Simple file transfer

I want to create an application in C that allows two users to share a file. I'll call the person sending the file the server and the receiver the client. There are a few requirements:
The users need no identification, no "login". You could say they are unknown for my application.
The server selects a file for transfer and gets returned a simple ~10 character ID string/hash that the client can use to retrieve the file.
The same application is used for both serving and receiving.
My application must not need dedicated software running on a remote server, unless it's freely available (e.g. bittorrent trackers).
Now this sounds a lot like bittorrent and I am seriously thinking of doing this through bittorrent. I'm not sure how I would do this. Are there any good libraries for torrent creation / seeding / downloading?
Please answer this question by either:
Posing a viable alternative for bittorrent / other ideas.
Posting good libraries / snippets / implementations of the bittorrent protocol in C.
This does indeed sound like something best done with BitTorrent. Have you had a look at libbt? It's not very well documented but does include a sample client, which is btget.c in /src/.
I have now found this library: rasterbar libtorrent. It's in C++ but I don't mind (I don't know either that well anyway).
Sharing here for future reference if other people are looking for the same thing as me.
And an other solution, send the file through an IRC server (like Freenode). I came up with this solution after I had trouble with opening ports with bittorrent.

Connect to a website via HTTP in C

I have some C code that parses a file and generates another file of processed data. I now need to post these files to a website on a web server. I guess there is a way to do a HTTP POST but I have never done this in c (using GCC on Ubuntu). Does anyone know how to do this? I need a starting point as I have no clue of doing this in C. I also need to be able to authenticate with the website.
libcurl is probably a good place to start.
I think Hank Gay's suggestion of using a library to handle the details is the best one, but if you want to "do it yourself", you need to open a socket to the web server and then send your data in the HTTP POST format which is described here. Authentication can mean a variety of different things, so you need to be more specific.
Unfortunately, all of the above three jobs involve a fair bit of complexity, so you need to break the question down into stages and come back and ask about each bit separately.

Resources