News: This forum is now permanently frozen.
Pages: [1]
Topic: Problems with m0n0backup.exe  (Read 1895 times)
« on: December 09, 2013, 16:31:08 »
descha *
Posts: 3

Hi all,
I try to backup my monowall (1.34) with the tool m0n0backup.exe from a windows machine.
All times the XML output is 1 KB and contains only 1 line:
Bad request token. Please make sure cookies are enabled and try again.

When I backup from the webgui everything works fine.

Any idea?

regards
Det
« Reply #1 on: December 09, 2013, 17:16:08 »
Lee Sharp *****
Posts: 517

Where are you getting this tool from?
« Reply #2 on: December 09, 2013, 17:39:28 »
Fred Grayson *****
Posts: 994

You may have problems with tools like this because m0n0wall has made changes to its webgui interface and certain pages now require a valid CSRF magic token.

--
Google is your friend and Bob's your uncle.
« Reply #3 on: December 09, 2013, 17:41:21 »
Fred Grayson *****
Posts: 994

@Lee the tool is available on the tools page: http://m0n0.ch/wall/tools.php

--
Google is your friend and Bob's your uncle.
« Reply #4 on: December 10, 2013, 02:48:44 »
Lee Sharp *****
Posts: 517

Ahhh!  When I search google I only found it on some odd download page, so I had...  Questions... Smiley
« Reply #5 on: December 10, 2013, 08:14:27 »
descha *
Posts: 3

Hi all,
thank you for fast reply, but is there any solution for using m0n0backup.
Or is there an other way to backup from a remote machine?

Tanks
Det
« Reply #6 on: December 10, 2013, 09:59:59 »
Pierre Nast *
Posts: 33

Hi,

You could use curl [1][2] in a batch file.

Pierre
[1] http://curl.haxx.se/
[2] http://ftp://ftp.sunet.se/pub/www/utilities/curl/

--
Pierre
« Reply #7 on: December 11, 2013, 16:58:58 »
Lee Sharp *****
Posts: 517

My first thought is "Why do you need a automated backup?"  How often is your configuration changing, and why?  I just pull a new backup when I am on the box changing something, and that is not very often...
« Reply #8 on: December 11, 2013, 17:31:11 »
Pierre Nast *
Posts: 33

Hi,

Like Lee, I don't see the point of doing automated backups.
But the original poster seems to need it, so here is a quick and dirty bash script that should do the trick :

Code:
#! /bin/bash

PROTO='http://'
if [ -x curl ]; then
echo "You need curl to run this script!"
fi
if [ $# -lt 1 -o $# -gt 2 ]; then
echo "usage: $0 <m0n0wall box's IP or hostname> [ssl]"
echo " ssl: if used, then curl will use https to access your box."
exit 1
elif [ $# -eq 2 -a "$2" = "ssl" ]; then
PROTO='https://'
fi
read -s -p "Enter admin password:" PASSWORD
CURL_OPTS="--basic --user admin:${PASSWORD} --insecure --stderr /dev/null"
IP="$1"
BACKUP_URL=${PROTO}${IP}/diag_backup.php
BACKUP_FILE="config-${IP}-$(date +%Y%m%d%H%M%S).xml"
echo -e "\nTrying to retrieve configuration from ${IP}..."
echo "Step 1 - Connecting to m0n0wall box to retrieve CSRF magic..."
CSRF=$(curl ${CURL_OPTS} ${BACKUP_URL} | \
grep '__csrf_magic' | \
sed "s#.*value=\"\(.*\)\".*#\1#")
if [ -z ${CSRF} ]; then
echo "Failed!"
exit 1
fi
echo "Done!"
echo "Step 2 - Downloading configuration from m0n0wall box..."
UPLOADED=$(curl ${CURL_OPTS} --referer ${BACKUP_URL} \
--form Submit=Download --form __csrf_magic=${CSRF} \
${BACKUP_URL} -o ${BACKUP_FILE}; echo $?)
if [ $UPLOADED -ne 0 ]; then
echo "Failed!"
exit 1
fi
echo "Done!"

Usage is simple :

pierre@tala:~/tmp$ ./m0n0backup.sh loki ssl
Enter admin password:
Trying to retrieve configuration from loki...
Step 1 - Connecting to m0n0wall box to retrieve CSRF magic...
Done!
Step 2 - Downloading configuration from m0n0wall box...
Done!
pierre@tala:~/tmp$ ls -lh config-*
-rw-rw-r-- 1 pierre pierre 27K déc.  11 17:28 config-loki-20131211172816.xml


Hope it'll help...

Pierre

--
Pierre
 
Pages: [1]
 
 
Powered by SMF 1.1.20 | SMF © 2013, Simple Machines