Announcement

Collapse
No announcement yet.

Python script snippet needed

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    [SOLVED] Python script snippet needed

    Hello,does anybody have a script that uploads the files in a folder to https://wigle.net/ ?
    It needs to log in with username and password.
    I have searched the net for a suitable snippet of code to use without luck.
    I have tried using:
    os.system('curl -u usernameassword https://wigle.net/gps/gps/main/postfile -F myfile=/kismet-logs/*') , but that does not work.
    Last edited by isprins; May 10, 2013, 07:05 AM.

    #2
    For simple interaction with a server, your "os.system" example may work. If the command between the quotes (' ') works in a shell on the command line, it should work there.

    There is more sophisticated interaction that can be done with pycurl a package available in python.

    Perhaps, if we could examine the errors returned by "curl" we could identify what is wrong. Try adding the '-v' (verbose) option to the command line of curl to get more information. It could be anything from bad server SSL authentication, to unknown URL, to unacceptable input with your "POST" request.

    Comment


      #3
      Ok. There is something weird going on with the curl command, i have tried several different :

      Code:
      [B]curl --user xxxxxx:xxxxxxx [url]https://wigle.net/gps/gps/main/postfile[/url] -F myfile=~/kismet-logs/*[/B]
      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
      <html><head><meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8"><title>WiGLE - Wireless Geographic Logging Engine - Post File</title><link REL="shortcut icon" HREF="/favicon.ico" TYPE="image/x-icon"><LINK REL="alternate" TITLE="WiGLE RSS" HREF="//wigle.net/gps/gps/RSS/wiglenews.xml" TYPE="application/rss+xml">
      <LINK REL="alternate" TITLE="WiGLE Statistics RSS" HREF="//wigle.net/gps/gps/StatRSS/wiglestats.xml" TYPE="application/rss+xml">
      <meta name="description" content="Maps and database of 802.11 wireless networks, with statistics, submitted by wardrivers, netstumblers, and net huggers.">
      <meta name="keywords" content="wifi,wireless,802.11,802.11b,wireless networks,wireless maps,maps,mapping,wireless mapping,wardriving,war driving,netstumbler,dstumbler,kismet,net hugger,net hugging">
      <meta name="google-site-verification" content="fFWa-EFp_gpCQFwZf7B_4qEjxOVcqQ4MtJ-l-aALf2E" />
      <link rel="stylesheet" type="text/css" href="/styles.css"><script language="javascript" TYPE="text/javascript">
      <!--
        function firstFocus()
          {
          if (document.forms.length > 0)
            {
            var TForm = document.forms[0];
            for (i=0;i<TForm.length;i++)
              {
              if ((TForm.elements[i].type=="text")||
                  (TForm.elements[i].type=="textarea")||
                  (TForm.elements[i].type=="textfield")||
                  (TForm.elements[i].type.toString().charAt(0)=="s"))
                {
                document.forms[0].elements[i].focus();
                break;
                }
              }
            }
          }
      // -->
              </script>
      </head><body onLoad="firstFocus()" class="content"><center><table class="launchitem"><tr><td>
      <a href="/gps/gps/main"><font size="-1">Home</font></a>
       | <a href="/gps/gps/main/download/"><font size="-1">Download</font></a>
       | <a href="/phpbb/"><font size="-1">Forums</font></a>
       | <a href="/gps/gps/main/postfile"><font size="-1">Post File</font></a>
       | Query
       | <a href="/gps/gps/main/screenshots/"><font size="-1">Screenshots</font></a>
       | <a href="/gps/gps/main/stats/"><font size="-1">Stats</font></a>
       | Uploads  | <a href="/gps/gps/Map/onlinemap2/"><font size="-1">Web Maps</font></a>
       | MapPacks/Trees | <a href="/wiki/index.cgi"><font size="-1">Wiki</font></a>
       | <a href="/gps/gps/main/login/"><font size="-1">Login</font></a>
      </td></tr>
      </td></tr></table></center>
      <center>
        <table width="90%">    <tr>
            <td class="launchitem">
              <table>
                <tr>
                  <td>
              <SPAN style="width:68px;height:68px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/images/wifi-upload.png');" ><IMG style="filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" SRC="/images/wifi-upload.png" alt="[upload]" ></SPAN>
                  </td><td>
            <h2>Upload File</h2>
                </td>
              </tr>
            </table>
            We currently support all of NetStumbler's exported and native files. <br><a href="http://www.netstumbler.com">NetStumbler</a> is a very well done 802.11b scouting tool for Windows.<br>We also support <a href="http://www.kismetwireless.net/">Kismet</a> for Linux and others, DStumbler for BSD, as well as some other file formats.<p>
            <b>Types supported:</b><br>
            <ul>
              <li><a href="http://petewarden.github.com/iPhoneTracker/#2">Consolidated.db</a>: This is an sqlite file that is synced from an iphone/ipad to a host computer (prior to iOS 4.3.3). <a href="http://petewarden.github.com/iPhoneTracker/#2">OSX details</a>. <a href="http://andykn.blogspot.com/2011/04/iphone-tracker.html">Windows details</a>. An easy way to get a copy of the files in your home dir on OSX is to start Terminal and run this (as a single line):</li>
      tar czvf consolidated.tar.gz ~/Library/Application*Support/MobileSync/Backup/????????????????????????????????????????/4096c9ec676f2847dc283405900e284a7c815836        <li><a href="http://www.bawug.org/howto/reviews/dstumbler.html">DStumbler</a>: text output<br></li>
              <li><a href="http://www.androlib.com/android.application.carknue-gmon-zjm.aspx">G-Mon</a>: .kml, .txt output</li>
              <li><a href="http://www.metageek.net/products/inssider">inSSIDer</a>: kml output</li>
              <li><a href="http://trac.kismac-ng.org/">Kismac</a>: native (.kismac), text, kml output</li>
              <li><a href="http://www.kismetwireless.net/">Kismet</a>: .csv, .xml, .netxml, .gps, .gpsxml, .nettxt, CWGD output<br></li>
              <li><a href="http://www.macstumbler.com/">MacStumbler</a>: plist xml, wiscan format<br></li>
              <li><a href="http://www.netstumbler.com">NetStumbler</a>: native (.ns1), text, wiscan, summary<br></li>
              <li><a href="http://www.pocketwarrior.org/">Pocket Warrior</a>: Text output</li>
              <li><a href="http://code.google.com/p/wardrive-android/">Wardrive-Android</a>: kml output</li>
              <li><a href="http://www.aspecto-software.com/rw/">WiFiFoFum</a>: kml output</li>
              <li><a href="http://www.threejacks.com/?q=node/13">WiFi-Where</a>: ns1, kml, csv output. Now available on Cydia (iphone/ipad jailbreak)</li>
              <li><a href="https://market.android.com/details?id=net.wigle.wigleandroid">Wigle Wifi Wardriving</a>: csv output</li>
            </ul><p>
          Note that you can send an individual file gzip'd, and if it ends in '.gz' it will be gunzip'd before being read (gzip is <b>not</b> the same as pkzip or winzip). You may send a gzipped tar archive -  <em>if</em> the file name ends in '.tar.gz' the individual members will be extracted and processed sequentially. You may send one or more files pkzipped (compressed using zip/winzip/pkzip/others), and they will be processed sequentially, although please note that new filenames will be assigned during processing.<p><p>
            <form action="/gps/gps/main/confirmfile/" METHOD="post" ENCTYPE="multipart/form-data">
                <b><font size="+2" color="#FF0000">Observer is set to: 'anonymous'</font></b> (<a href="/gps/gps/main/register">register</a> and <a href="/gps/gps/GPSDB/login/?destination=/gps/gps/main/postfile/">log in</a> 
       to get credit for your submission)<p>
                <b><font size="+2" color="#FF0000">You are NOT logged in!!!</font></b><br>
                <b><font size="+2" color="#FF0000">You are NOT logged in!!!</font></b><br>
                <b><font size="+2" color="#FF0000">You are NOT logged in!!!</font></b><br>
                <b><font size="+2" color="#FF0000">You are NOT logged in!!!</font></b><br>
                <b><font size="+2" color="#FF0000">You are NOT logged in!!!</font></b><br>
      user: <input type="text" NAME="observer" value="anonymous" SIZE=10 MAXLENGTH=10> 
       password: <input type="password" NAME="password" SIZE=10 MAXLENGTH=32>&nbsp;&nbsp; 
      <INPUT TYPE="checkbox" NAME="noexpire"> Don't expire auth cookie<p>          Set file to upload:<br>          <input type="file" name="stumblefile" size="42"><p>
                <input type="Submit" name="Send" value="Send"> <input type="Reset" name="Clear">
              </form><p>
            </td>
          </tr>
          <tr>
            <td>
              <p><p>
              <a href="/"><font color="#FF0000">Wi</font><font color="#006600">G</font><font color="#0000FF">L</font><font color="#FF00FF">E</font> Home</a><a href="/"><p>
              <br>
            </td>
          </tr>
          <tr>
        </table>
      </center>
      </body></html>
      This one seems to connect, but it does not upload the files in /kismet-logs/

      Code:
      [B]curl -u  xxxxxxxx:xxxxx [url]https://wigle.net/gps/gps/main/postfile[/url] -v -F myfile=~/kismet-logs/*[/B]
      * About to connect() to wigle.net port 443 (#0)
      *   Trying 205.234.142.193...
      * Connected to wigle.net (205.234.142.193) port 443 (#0)
      * successfully set certificate verify locations:
      *   CAfile: none
        CApath: /etc/ssl/certs
      * SSLv3, TLS handshake, Client hello (1):
      * SSLv3, TLS handshake, Server hello (2):
      * SSLv3, TLS handshake, CERT (11):
      * SSLv3, TLS handshake, Server key exchange (12):
      * SSLv3, TLS handshake, Server finished (14):
      * SSLv3, TLS handshake, Client key exchange (16):
      * SSLv3, TLS change cipher, Client hello (1):
      * SSLv3, TLS handshake, Finished (20):
      * SSLv3, TLS change cipher, Client hello (1):
      * SSLv3, TLS handshake, Finished (20):
      * SSL connection using DHE-RSA-AES256-SHA
      * Server certificate:
      *        subject: O=www.wigle.net; OU=Domain Control Validated; CN=www.wigle.net
      *        start date: 2011-04-24 00:55:30 GMT
      *        expire date: 2014-04-24 00:55:30 GMT
      *        subjectAltName: wigle.net matched
      *        issuer: C=US; ST=Arizona; L=Scottsdale; O=Starfield Technologies, Inc.; OU=http://certificates.starfieldtech.com/repository; CN=Starfield Secure Certification Authority; serialNumber=10688435
      *        SSL certificate verify ok.
      * Server auth using Basic with user 'xxxxxxxx'
      > POST /gps/gps/main/postfile HTTP/1.1
      > Authorization: Basic c3VwZXJtYWc6ZXN0Njc3dmU=
      > User-Agent: curl/7.29.0
      > Host: wigle.net
      > Accept: */*
      > Content-Length: 167
      > Expect: 100-continue
      > Content-Type: multipart/form-data; boundary=----------------------------a16a80eb5a5b
      > 
      < HTTP/1.1 100 Continue
      < HTTP/1.1 200 OK
      < Date: Fri, 10 May 2013 22:49:41 GMT
      < Server: Apache/2.2.22 (Fedora)
      < Vary: Accept-Encoding,User-Agent
      < Connection: close
      < Transfer-Encoding: chunked
      < Content-Type: text/html; charset=UTF-8
      < 
      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
      <html><head><meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8"><title>WiGLE - Wireless Geographic Logging Engine - Post File</title><link REL="shortcut icon" HREF="/favicon.ico" TYPE="image/x-icon"><LINK REL="alternate" TITLE="WiGLE RSS" HREF="//wigle.net/gps/gps/RSS/wiglenews.xml" TYPE="application/rss+xml">
      <LINK REL="alternate" TITLE="WiGLE Statistics RSS" HREF="//wigle.net/gps/gps/StatRSS/wiglestats.xml" TYPE="application/rss+xml">
      <meta name="description" content="Maps and database of 802.11 wireless networks, with statistics, submitted by wardrivers, netstumblers, and net huggers.">
      <meta name="keywords" content="wifi,wireless,802.11,802.11b,wireless networks,wireless maps,maps,mapping,wireless mapping,wardriving,war driving,netstumbler,dstumbler,kismet,net hugger,net hugging">
      <meta name="google-site-verification" content="fFWa-EFp_gpCQFwZf7B_4qEjxOVcqQ4MtJ-l-aALf2E" />
      <link rel="stylesheet" type="text/css" href="/styles.css"><script language="javascript" TYPE="text/javascript">
      <!--
        function firstFocus()
          {
          if (document.forms.length > 0)
            {
            var TForm = document.forms[0];
            for (i=0;i<TForm.length;i++)
              {
              if ((TForm.elements[i].type=="text")||
                  (TForm.elements[i].type=="textarea")||
                  (TForm.elements[i].type=="textfield")||
                  (TForm.elements[i].type.toString().charAt(0)=="s"))
                {
                document.forms[0].elements[i].focus();
                break;
                }
              }
            }
          }
      // -->
              </script>
      </head><body onLoad="firstFocus()" class="content"><center><table class="launchitem"><tr><td>
      <a href="/gps/gps/main"><font size="-1">Home</font></a>
       | <a href="/gps/gps/main/download/"><font size="-1">Download</font></a>
       | <a href="/phpbb/"><font size="-1">Forums</font></a>
       | <a href="/gps/gps/main/postfile"><font size="-1">Post File</font></a>
       | Query
       | <a href="/gps/gps/main/screenshots/"><font size="-1">Screenshots</font></a>
       | <a href="/gps/gps/main/stats/"><font size="-1">Stats</font></a>
       | Uploads  | <a href="/gps/gps/Map/onlinemap2/"><font size="-1">Web Maps</font></a>
       | MapPacks/Trees | <a href="/wiki/index.cgi"><font size="-1">Wiki</font></a>
       | <a href="/gps/gps/main/login/"><font size="-1">Login</font></a>
      </td></tr>
      </td></tr></table></center>
      <center>
        <table width="90%">    <tr>
            <td class="launchitem">
              <table>
                <tr>
                  <td>
              <SPAN style="width:68px;height:68px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/images/wifi-upload.png');" ><IMG style="filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" SRC="/images/wifi-upload.png" alt="[upload]" ></SPAN>
                  </td><td>
            <h2>Upload File</h2>
                </td>
              </tr>
            </table>
            We currently support all of NetStumbler's exported and native files. <br><a href="http://www.netstumbler.com">NetStumbler</a> is a very well done 802.11b scouting tool for Windows.<br>We also support <a href="http://www.kismetwireless.net/">Kismet</a> for Linux and others, DStumbler for BSD, as well as some other file formats.<p>
            <b>Types supported:</b><br>
            <ul>
              <li><a href="http://petewarden.github.com/iPhoneTracker/#2">Consolidated.db</a>: This is an sqlite file that is synced from an iphone/ipad to a host computer (prior to iOS 4.3.3). <a href="http://petewarden.github.com/iPhoneTracker/#2">OSX details</a>. <a href="http://andykn.blogspot.com/2011/04/iphone-tracker.html">Windows details</a>. An easy way to get a copy of the files in your home dir on OSX is to start Terminal and run this (as a single line):</li>
      tar czvf consolidated.tar.gz ~/Library/Application*Support/MobileSync/Backup/????????????????????????????????????????/4096c9ec676f2847dc283405900e284a7c815836        <li><a href="http://www.bawug.org/howto/reviews/dstumbler.html">DStumbler</a>: text output<br></li>
              <li><a href="http://www.androlib.com/android.application.carknue-gmon-zjm.aspx">G-Mon</a>: .kml, .txt output</li>
              <li><a href="http://www.metageek.net/products/inssider">inSSIDer</a>: kml output</li>
              <li><a href="http://trac.kismac-ng.org/">Kismac</a>: native (.kismac), text, kml output</li>
              <li><a href="http://www.kismetwireless.net/">Kismet</a>: .csv, .xml, .netxml, .gps, .gpsxml, .nettxt, CWGD output<br></li>
              <li><a href="http://www.macstumbler.com/">MacStumbler</a>: plist xml, wiscan format<br></li>
              <li><a href="http://www.netstumbler.com">NetStumbler</a>: native (.ns1), text, wiscan, summary<br></li>
              <li><a href="http://www.pocketwarrior.org/">Pocket Warrior</a>: Text output</li>
              <li><a href="http://code.google.com/p/wardrive-android/">Wardrive-Android</a>: kml output</li>
              <li><a href="http://www.aspecto-software.com/rw/">WiFiFoFum</a>: kml output</li>
              <li><a href="http://www.threejacks.com/?q=node/13">WiFi-Where</a>: ns1, kml, csv output. Now available on Cydia (iphone/ipad jailbreak)</li>
              <li><a href="https://market.android.com/details?id=net.wigle.wigleandroid">Wigle Wifi Wardriving</a>: csv output</li>
            </ul><p>
          Note that you can send an individual file gzip'd, and if it ends in '.gz' it will be gunzip'd before being read (gzip is <b>not</b> the same as pkzip or winzip). You may send a gzipped tar archive -  <em>if</em> the file name ends in '.tar.gz' the individual members will be extracted and processed sequentially. You may send one or more files pkzipped (compressed using zip/winzip/pkzip/others), and they will be processed sequentially, although please note that new filenames will be assigned during processing.<p><p>
            <form action="/gps/gps/main/confirmfile/" METHOD="post" ENCTYPE="multipart/form-data">
                <b><font size="+2" color="#FF0000">Observer is set to: 'anonymous'</font></b> (<a href="/gps/gps/main/register">register</a> and <a href="/gps/gps/GPSDB/login/?destination=/gps/gps/main/postfile/">log in</a> 
       to get credit for your submission)<p>
                <b><font size="+2" color="#FF0000">You are NOT logged in!!!</font></b><br>
                <b><font size="+2" color="#FF0000">You are NOT logged in!!!</font></b><br>
                <b><font size="+2" color="#FF0000">You are NOT logged in!!!</font></b><br>
                <b><font size="+2" color="#FF0000">You are NOT logged in!!!</font></b><br>
                <b><font size="+2" color="#FF0000">You are NOT logged in!!!</font></b><br>
      user: <input type="text" NAME="observer" value="anonymous" SIZE=10 MAXLENGTH=10> 
       password: <input type="password" NAME="password" SIZE=10 MAXLENGTH=32>&nbsp;&nbsp; 
      <INPUT TYPE="checkbox" NAME="noexpire"> Don't expire auth cookie<p>          Set file to upload:<br>          <input type="file" name="stumblefile" size="42"><p>
                <input type="Submit" name="Send" value="Send"> <input type="Reset" name="Clear">
              </form><p>
            </td>
          </tr>
          <tr>
            <td>
              <p><p>
              <a href="/"><font color="#FF0000">Wi</font><font color="#006600">G</font><font color="#0000FF">L</font><font color="#FF00FF">E</font> Home</a><a href="/"><p>
              <br>
            </td>
          </tr>
          <tr>
        </table>
      </center>
      </body></html>
      * Closing connection 0
      * SSLv3, TLS alert, Client hello (1):
      Code:
      [B]curl -u -v xxxxxxx:xxxxxxxx [url]https://wigle.net/gps/gps/main/postfile[/url] -F myfile=~/kismet-logs/*[/B]
      Enter host password for user '-v':
      curl: (6) Couldn't resolve host 'xxxxxxxx'
      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
      <html><head><meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8"><title>WiGLE - Wireless Geographic Logging Engine - Post File</title><link REL="shortcut icon" HREF="/favicon.ico" TYPE="image/x-icon"><LINK REL="alternate" TITLE="WiGLE RSS" HREF="//wigle.net/gps/gps/RSS/wiglenews.xml" TYPE="application/rss+xml">
      <LINK REL="alternate" TITLE="WiGLE Statistics RSS" HREF="//wigle.net/gps/gps/StatRSS/wiglestats.xml" TYPE="application/rss+xml">
      <meta name="description" content="Maps and database of 802.11 wireless networks, with statistics, submitted by wardrivers, netstumblers, and net huggers.">
      <meta name="keywords" content="wifi,wireless,802.11,802.11b,wireless networks,wireless maps,maps,mapping,wireless mapping,wardriving,war driving,netstumbler,dstumbler,kismet,net hugger,net hugging">
      <meta name="google-site-verification" content="fFWa-EFp_gpCQFwZf7B_4qEjxOVcqQ4MtJ-l-aALf2E" />
      <link rel="stylesheet" type="text/css" href="/styles.css"><script language="javascript" TYPE="text/javascript">
      <!--
        function firstFocus()
          {
          if (document.forms.length > 0)
            {
            var TForm = document.forms[0];
            for (i=0;i<TForm.length;i++)
              {
              if ((TForm.elements[i].type=="text")||
                  (TForm.elements[i].type=="textarea")||
                  (TForm.elements[i].type=="textfield")||
                  (TForm.elements[i].type.toString().charAt(0)=="s"))
                {
                document.forms[0].elements[i].focus();
                break;
                }
              }
            }
          }
      // -->
              </script>
      </head><body onLoad="firstFocus()" class="content"><center><table class="launchitem"><tr><td>
      <a href="/gps/gps/main"><font size="-1">Home</font></a>
       | <a href="/gps/gps/main/download/"><font size="-1">Download</font></a>
       | <a href="/phpbb/"><font size="-1">Forums</font></a>
       | <a href="/gps/gps/main/postfile"><font size="-1">Post File</font></a>
       | Query
       | <a href="/gps/gps/main/screenshots/"><font size="-1">Screenshots</font></a>
       | <a href="/gps/gps/main/stats/"><font size="-1">Stats</font></a>
       | Uploads  | <a href="/gps/gps/Map/onlinemap2/"><font size="-1">Web Maps</font></a>
       | MapPacks/Trees | <a href="/wiki/index.cgi"><font size="-1">Wiki</font></a>
       | <a href="/gps/gps/main/login/"><font size="-1">Login</font></a>
      </td></tr>
      </td></tr></table></center>
      <center>
        <table width="90%">    <tr>
            <td class="launchitem">
              <table>
                <tr>
                  <td>
              <SPAN style="width:68px;height:68px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/images/wifi-upload.png');" ><IMG style="filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" SRC="/images/wifi-upload.png" alt="[upload]" ></SPAN>
                  </td><td>
            <h2>Upload File</h2>
                </td>
              </tr>
            </table>
            We currently support all of NetStumbler's exported and native files. <br><a href="http://www.netstumbler.com">NetStumbler</a> is a very well done 802.11b scouting tool for Windows.<br>We also support <a href="http://www.kismetwireless.net/">Kismet</a> for Linux and others, DStumbler for BSD, as well as some other file formats.<p>
            <b>Types supported:</b><br>
            <ul>
              <li><a href="http://petewarden.github.com/iPhoneTracker/#2">Consolidated.db</a>: This is an sqlite file that is synced from an iphone/ipad to a host computer (prior to iOS 4.3.3). <a href="http://petewarden.github.com/iPhoneTracker/#2">OSX details</a>. <a href="http://andykn.blogspot.com/2011/04/iphone-tracker.html">Windows details</a>. An easy way to get a copy of the files in your home dir on OSX is to start Terminal and run this (as a single line):</li>
      tar czvf consolidated.tar.gz ~/Library/Application*Support/MobileSync/Backup/????????????????????????????????????????/4096c9ec676f2847dc283405900e284a7c815836        <li><a href="http://www.bawug.org/howto/reviews/dstumbler.html">DStumbler</a>: text output<br></li>
              <li><a href="http://www.androlib.com/android.application.carknue-gmon-zjm.aspx">G-Mon</a>: .kml, .txt output</li>
              <li><a href="http://www.metageek.net/products/inssider">inSSIDer</a>: kml output</li>
              <li><a href="http://trac.kismac-ng.org/">Kismac</a>: native (.kismac), text, kml output</li>
              <li><a href="http://www.kismetwireless.net/">Kismet</a>: .csv, .xml, .netxml, .gps, .gpsxml, .nettxt, CWGD output<br></li>
              <li><a href="http://www.macstumbler.com/">MacStumbler</a>: plist xml, wiscan format<br></li>
              <li><a href="http://www.netstumbler.com">NetStumbler</a>: native (.ns1), text, wiscan, summary<br></li>
              <li><a href="http://www.pocketwarrior.org/">Pocket Warrior</a>: Text output</li>
              <li><a href="http://code.google.com/p/wardrive-android/">Wardrive-Android</a>: kml output</li>
              <li><a href="http://www.aspecto-software.com/rw/">WiFiFoFum</a>: kml output</li>
              <li><a href="http://www.threejacks.com/?q=node/13">WiFi-Where</a>: ns1, kml, csv output. Now available on Cydia (iphone/ipad jailbreak)</li>
              <li><a href="https://market.android.com/details?id=net.wigle.wigleandroid">Wigle Wifi Wardriving</a>: csv output</li>
            </ul><p>
          Note that you can send an individual file gzip'd, and if it ends in '.gz' it will be gunzip'd before being read (gzip is <b>not</b> the same as pkzip or winzip). You may send a gzipped tar archive -  <em>if</em> the file name ends in '.tar.gz' the individual members will be extracted and processed sequentially. You may send one or more files pkzipped (compressed using zip/winzip/pkzip/others), and they will be processed sequentially, although please note that new filenames will be assigned during processing.<p><p>
            <form action="/gps/gps/main/confirmfile/" METHOD="post" ENCTYPE="multipart/form-data">
                <b><font size="+2" color="#FF0000">Observer is set to: 'anonymous'</font></b> (<a href="/gps/gps/main/register">register</a> and <a href="/gps/gps/GPSDB/login/?destination=/gps/gps/main/postfile/">log in</a> 
       to get credit for your submission)<p>
                <b><font size="+2" color="#FF0000">You are NOT logged in!!!</font></b><br>
                <b><font size="+2" color="#FF0000">You are NOT logged in!!!</font></b><br>
                <b><font size="+2" color="#FF0000">You are NOT logged in!!!</font></b><br>
                <b><font size="+2" color="#FF0000">You are NOT logged in!!!</font></b><br>
                <b><font size="+2" color="#FF0000">You are NOT logged in!!!</font></b><br>
      user: <input type="text" NAME="observer" value="anonymous" SIZE=10 MAXLENGTH=10> 
       password: <input type="password" NAME="password" SIZE=10 MAXLENGTH=32>&nbsp;&nbsp; 
      <INPUT TYPE="checkbox" NAME="noexpire"> Don't expire auth cookie<p>          Set file to upload:<br>          <input type="file" name="stumblefile" size="42"><p>
                <input type="Submit" name="Send" value="Send"> <input type="Reset" name="Clear">
              </form><p>
            </td>
          </tr>
          <tr>
            <td>
              <p><p>
              <a href="/"><font color="#FF0000">Wi</font><font color="#006600">G</font><font color="#0000FF">L</font><font color="#FF00FF">E</font> Home</a><a href="/"><p>
              <br>
            </td>
          </tr>
          <tr>
        </table>
      </center>
      </body></html>
      Last edited by SteveRiley; May 10, 2013, 09:06 PM. Reason: formatting

      Comment


        #4
        When you fill in an HTML form with curl, you first have to determine a few requirements:
        • the URL to which the form will be sent
        • whether to use the GET or POST methods
        • which encoding method is expected
        • the name of each <input> field and button

        Looking at the HTML of the form in question here, we see this line:
        Code:
        <form action="/gps/gps/main/confirmfile/" method="post" enctype="multipart/form-data">
        Now we have the first three requirements:
        What remains is to find the necessary <input> fields and buttons. These will usually be in the format
        Code:
        <input type="[I]some-type[/I]" name="[I]field-name[/I]" value="[I]default-value[/I]" . . . >
        Because this is a multipart/form-data form, we have to include the -F (or --form) parameter, once for each field and button on the form. Note that -F is not simply for a file name, as it appears you suspect. Also, curl's other form-filling parameter, -d (or --data), is for form type application/x-www-form-urlencoded, which is not the correct one for the form you're asking about.

        Furthermore, you can't use the -u (or --user) parameter the way you think. This parameter works for basic, digest, or SSPI authentication, but it will not work for forms authentication. We can see that the page is using forms authentication because the HTML contains fields for that purpose and does not contain any of the HTML commands that specify other kinds of authentication. Therefore, we have to use the -F parameter to supply the login data, too.

        I see four fields of importance:
        Code:
        user: <input type="text" [B]name="observer"[/B] value="anonymous" size="10" maxlength="10">
        
        password: <input type="password" [B]name="password"[/B] size="10" maxlength="32">
        
        Set file to upload: <input type="file" [B]name="stumblefile"[/B] size="42">
        
        Send button: <input type="Submit" [B]name="Send"[/B] value="Send">
        The curl syntax for filling in form fields follows follows this syntax:
        Code:
        -F field-name=value
        Where field-name is the field name you see in the HTML and value is the data you want to supply in the field.

        If you want the form to upload the contents of a file, place an @ sign in front of the file name:
        Code:
        -F field-name=@/path/to/file
        where /path/to/file is the file you wish to send along with the form.

        I created a 10K file of random garbage generated thusly:
        Code:
        dd if=/dev/urandom of=junk.txt bs=10K count=1
        Then I tried uploading it anonymously, which worked:
        Code:
        steve@t520:~$ [B]curl -v -F observer=anonymous -F stumblefile=@junk.txt -F Send=Send https://wigle.net/gps/gps/main/confirmfile/[/B]
        . . .
        <h2>Upload Results</h2>
        <p>File 'junk.txt' uploaded successfully! (10240 bytes)<br>
        Thanks!<p>
        File: 1368240133_junk.txt Transaction ID :20130510-00479<p>
        . . .
        If you had an account there, the command you'd use is:
        Code:
        curl -F observer=[I]your-user-name[/I] -F password=[I]your-password[/I] -F stumblefile=@[I]/path/to/file[/I] -F Send=Send https://wigle.net/gps/gps/main/confirmfile/
        So it appears you can accomplish your task with a single curl command, without having to wrap it inside a Python script.
        Last edited by SteveRiley; May 10, 2013, 09:27 PM.

        Comment


          #5
          Thanks for the help!

          This is how my script ended up, sadly this forum messes up the code a bit.

          Code:
          #wardrive-led-controll
          #This is a Python script that controlls the leds on a
          #Berryclip connected to the GPIO header on a
          #Rasberry Pi model B.
          #It checks if kismet_server and gpsd is running,and controlls LED1 and LED2 accordingly.
          #It also does upload the logfiles if the switch
          #connected to pin 26/GPIO07 is momentarily toggled.
          #Notes:
          #WARNING! wardriving may not be legal in your country, so CHECK THE LOCAL LAWS!
          #Your wlan node must be in reach, and have a good stable signal for upload to work!
          #wpa_supplicant.conf must be configured correctly!
          #The name of the wlan interface you are using must be correct, its normally wlan0.
          #kimset_server or kismet and gpsd must be auto-started at boot.
          #kismet_server must be configured correctly,running as SUID and log to netxml and gpsxml.
          #A GPS reciver that is compatilble with gpsd must be connected to one of the USB ports.
          #A usb wlan dongle that is supported in Debian/linux must be connected with USB.
          #Anyone can improve this script and correct it,if they share it with the rest of the world.
          #
          #
          #The Berryclips pinout is:
          #LED 1 - Pin 7 - GPIO4
          #LED 2 - Pin 11 - GPIO17
          #LED 3 - Pin 15 - GPIO22
          #LED 4 - Pin 19 - GPIO10
          #LED 5 - Pin 21 - GPIO9
          #LED 6 - Pin 23 - GPIO11
          #Buzzer - Pin 24 - GPIO8
          #Switch - Pin 26 - GPIO7
          #To do: Implement flashing of LED6 every time kismet detects a WLAN packet. I dont have the
          #knowledge of how to do that.
          #Perhaps via kismets tuntap interface ?
          #Implement controll of LED3, if the gps connected to gpsd has a position fix.
          #Sadly my knowledge of python is extremely small.
          import RPi.GPIO as GPIO
          import os
          import subprocess
          import gps
          GPIO.setwarnings(False)
          GPIO.setmode(GPIO.BOARD)
          GPIO.setup(4, GPIO.OUT)#LED1 KISMET.
          GPIO.setup(22, GPIO.OUT)#LED3 GPS position fix
          GPIO.setup(17, GPIO.OUT)#LED2 GPSD running.
          GPIO.setup(9, GPIO.OUT)#LED5 Upload in progress.
          GPIO.setup(26, GPIO.IN)#Data upload switch,momentarily toggle.
          #Makes sure all LED's are at the same state initially (off):
          GPIO.output(4, True)
          GPIO.output(17, True)
          GPIO.output(22, True)
          GPIO.output(9, True)
          GPIO.output(10, True)
          while 1 < 2:
          	kismet = subprocess.Popen(['ps -ef | grep kismet_server'])#checks if kismet_server is running.
          	stdout = subprocess.PIPE, shell=True() #Assigns the output from the grep to the kismet variable.
          	(output, error) = kismet.communicate()
          	if 'kismet_server' in output: GPIO.output(4, False) #Turn on KISMET LED
          else:
          	GPIO.output(4, True) #Turn off KISMET LED.
          	gps = subprocess.Popen(['ps -ef | grep gpsd'],
          	stdout = subprocess.PIPE, shell=True)#Assigns the output from the grep to the gps variable 
          	(output, error) = gps.communicate() 
          	if 'gpsd' in output: GPIO.output(17, False) #Turn on GPSD LED.
          	else:
          		GPIO.output(17, True) #Turn off GPSD LED
          #Button snippet,connects to your wlan node,and stops kismet_server,also uploads the logfiles to wigle.net
          while True:
          	if (GPIO.input(26)):
          		time.sleep(0.05)#Button debounce.
          		os.system('killall kismet')#stops all instances of kismet.
          		os.system('killall kismet_server')#stops all instances of kismet_server.
          		time.sleep(2)# added so kismet has the time to die.		
          		os.system('/etc/init.d/networking restart')#restarts networking
          		time.sleep(1.5)#wait for networking to restart.
          		os.system('wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf')#connects to your wlan node.
          		time.sleep(10)#added so wlan0 has time to autenticate and assosiate with the wlan node.
          		command = os.system('ping -c 5 [url]http://www.wigle.net')#checks[/url] if wigle.net is up.
          		if command == 0: print "wigle.net is up."
          #This metod of uploading the logfiles to wigle.net works, but it is perhaps a bit ackward.
          	os.system('mv path/to/kismet-logs/*.gpsxml /path/to/kismet-logs/upload.gpsxml')#renames the gpsxml file so the curl #command can use it,because the curl command does not support wildcards.
          	os.system('mv /pathto/kismet-logs/*.netxml /pathto/kismet-logs/upload.netxml')#renames the gpsxml file so the curl #command can use it,because the curl command does not support wildcards.
          	os.system('curl -F observer=your-wigleusername -F password=your-password -F stumblefile=@/pathto/kismet-logs/upload.gpsxml -F Send=Send [url]https://wigle.net/gps/gps/main/confirmfile/')#uploads[/url] the gpsxml file.
          	time.sleep(17)#waits 17 seconds so the upload has time to complete,perhaps there is a more elegant solution?
          	os.system('curl -F observer=your-wigle.username -F password=your-password -F stumblefile=@/path-to/kismet-logs/upload.netxml -F Send=Send [url]https://wigle.net/gps/gps/main/confirmfile/')#uploads[/url] the gpsxml file.
          	time.sleep(17)#waits 17 seconds so the upload has time to complete,perhaps there is a more elegant solution?
          	#removes the uploaded log files:
          	os.system('rm /path-to/kismet-logs/*.gpsxml')
          	os.system('rm /path-to/kismet-logs/*.netxml')
          	command = os.system('ifconfig wlan0 down')#disables the wireless interface, i think thats a "ugly" way to disconnect.
          	command = os.system('dhclient -r wlan0')#Releases the DHCP IP.
          	command = os.system('ifconfig wlan0 up')#turns the interface back on, so kismet can access it.
          	time.sleep(1.5)#pause so wlan0 has time to come up.
          	command = os.system('kismet_server')#restarts kismet_server to resume scanning.
          	GPIO.output(9, False)#Turns off LED5.
          else: 
          		print "Wigle.net is down."

          Comment

          Working...
          X