![]() |
|
Tutorial Creating an Upload File Command - Printable Version +- Sinisterly (https://sinister.li) +-- Forum: Hacking (https://sinister.li/Forum-Hacking) +--- Forum: Tutorials (https://sinister.li/Forum-Tutorials) +--- Thread: Tutorial Creating an Upload File Command (/Thread-Tutorial-Creating-an-Upload-File-Command) |
Creating an Upload File Command - sunjester - 11-25-2018 Introduction High again, this tutorial will be dependent on Ubuntu and the ever-so-awesome terminal. This tutorial is going to show you how to create your own command to upload a file to the anonfile website. Just so you are aware, I have never seen this website before 10 minutes ago, when I had the idea for this tutorial when I notice it offered API. Creating Commands The command we are going to create will be called aup, standing for "anon upload". To be sure this can happen, let's see if the command already exists on the system. If it doesn't exist we will get an error, "command not found". Code: (xenial)sunjester@localhost:/var/www/html$ sudo aup
sudo: aup: command not foundLooks like we are set to make our command and it's super easy to do this. To add a new command you will want to add it in your .bashrc file. The bashrc file executes every time you log into your shell. If you were to simply execute an alias command without putting it in your bashrc file, it wouldn't be available the next time you log into the shell. Bash Function While I was looking and testing the command from the API they provided, it soon became apparent that it was going to be a pain in the ass to do this with a single alias command. Yes, you can do it, but I'm not going to use a single command. I am going to write a small function instead. This function needs to go into your bashrc file. Code: function __aup
{
curl -F "file=@"$1 "https://anonfile.com/api/upload"
}
alias aup='__aup'In the code above the argument we pass to the command is the file we want to upload, it is denoted by $1. If we had kept the single alias command we would have used something like $@, which conflicted with their weird API call. As you can see, our code is nice and clean when we use a function and of course, we have to call our alias command. There is no man page for alias, at least on my machine, which is super weird. After we edit the bashrc file we are going to have to use source to apply the changes. If you don't use the source command you will have to log out and then log back into the shell before changes take effect. Code: source ~/.bashrcFormatting the JSON When you execute your new command you will notice that the JSON is returned, and it's ugly. Code: (xenial)sunjester@localhost:~/Downloads/proxy_scrape$ aup proxylist
{"status":true,"data":{"file":{"url":{"full":"https://anonfile.com/Obr7V9l3bc/proxylist","short":"https://anonfile.com/Obr7V9l3bc"},"metadata":{"id":"Obr7V9l3bc","name":"proxylist","size":{"bytes":5537,"readable":"5.54 KB"}}}}}(xenial)sunjester@localhost:~/Downloads/proxy_scrape$There are tons of options you have for formatting the results, my personal favorite would be to regex it with sed, but to each their own. RE: Creating an Upload File Command - mothered - 11-25-2018 Quote:There are tons of options you have for formatting the results, my personal favorite would be to regex It I use this (regular expression) quite often. Simple to use, yet very effective. Appreciate the In depth guide. |