Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,772,106 Members 40,682 Now Online
XDA Developers Android and Mobile Development Forum

[XAP][Source] Webserver v0.5.3 (.REG download)

Tip us?
 
GoodDayToDie
Old
(Last edited by GoodDayToDie; 7th August 2014 at 11:28 AM.) Reason: Update 0.5.3
#1  
Recognized Developer - OP
Thanks Meter 2678
Posts: 5,627
Join Date: Jan 2011
Location: Seattle
Drive [XAP][Source] Webserver v0.5.3 (.REG download)

New, version Alpha 0.5.3, is now up on Codeplex and available for download here!
OK, a bit quicker that time. The major change this time is the addition of a button to download a registry key (including all its subkeys, and of course all their values) as a .REG file. Other changes include better handling of relative paths and path traversal in the file system, a "go up" link in the registry, and bugfixes on some of the more esoteric registry behaviors. Oh, and the ability to open the phone's web browser, pointing at the server, from within the app (the URL is now a link).

Previous update (0.5.1): OK, the main advantage of the new version is nothing complex: a large number of capabilities have been added, giving access to some parts of the file system and registry that were previously unreachable. Obviously, this is only in the AllCapabilities version. This version is still compatible with GDR3; I haven't targeted 8.1 yet. The other change, which impacts the standard-capability version as well, is that a lot of the initial navigation is now cleaner and the static pages have received script tweaks to improve navigation. Also, it is now clearly stated when the current path has no subkeys/values/files, and the ../ directory entry simply takes you to the parent directory instead of literally appending .. (although that still works, if you want to use it).

PLEASE REPORT ANY BUGS YOU FIND IN THE CURRENTLY IMPLEMENTED FEATURES, ESPECIALLY THE NEW ONES! The .REG file creation had to be written from scratch - I can call the native function that's supposed to do it, but if fails unless you have SeBackupPrivilege, which I haven't been able to add to an app - and it probably needs more testing. I also don't actually promise that the .REG files are importable using regedit; they should be but I have *not* tested that. I made some unusual choices in how the file is generated (everything is presented as binary, which means I didn't need to worry about things like quotes in strings or DWORDs that are 20 bytes long. I also embedded a ton of comments, including the non-binary representations of the values. Speed is pretty good but very un-optimized so I may improve it later (in the meantime, downloading all of HKLM at once will take a little while).

I still plan to implement upload/write operations... some day! I'm also looking at moving the server to a background process and making the app just a control UI for it, adding support for authentication and/or HTTPS, adding some stylesheets to the web UI, adding cache control, and much more.

As with the last few releases, the XAP is published twice; once as a fairly standard XAP that any phone can sideload, the second with many exotic capabilities to enable viewing of slightly more of the file system. The standard XAP has had its list of capabilities expanded to pretty much all of them that can be used without interop-unlock. The high-capability variant requires not just interop-unlock, but the additional capability-unlock hack available in the interop-unlock thread.

An item of note: the AllCapabilities version can open other drives in the file system. On phones with an SD card, it is mounted at D:\ and you can browse it as normal. Credit to @hjc4869 for this discovery!

Version 0.5.3 comes with an update to the NativeAccess libraries as well, in particular an improvement to the Registry::RegistryKey class that was never really there before. I plan to add some of the stuff in the new library versions, such as process listing, "soon" though. The HttpServer also got a small update.

This is a very basic webserver app which can enumerate those files that are in folders readable from the sandbox, can download files, can browse the registry, and can display the contents of registry values of any type. It runs on WP8.x only. It is a spiritual successor to the Functional Webserver / WebServer (Mango) projects from WP7. This version is still missing a lot of functionality as I decided to implement it from scratch, but it is advancing swiftly. Note that there's no access controls implemented; use it on a public network only at your own risk!

Instructions are simple: sideload the XAP, connect to WiFi (required), run the app (called "WebServer Native Access"), point a web browser (on a PC or phone that is also on that local network) to the URL that the app displays. You should get a basic index page. Click on a Filesystem or Registry link to begin browsing the phone. There's a textbox near the top of all filesystem pages, type in a path there (for example, "\windows" with no quotes) and hit Enter or click Get Files. You'll see a list of the contents of that folder. Click on a file to download it or a directory to open it. Navigating the registry is similar, except you'll need to specify the registry hive and then the path from that hive (or no path, to access the root of the hive).

Modifications (uploading or editing files, creating, deleting, or changing registry keys or values) are currently not supported. They will be "soon" although my personal testing suggests that basically the whole registry, and most of the file system, is off-limits for writing unless you use restricted capabilities. Interestingly, I can *read* most of the registry, including stuff that I probably shouldn't be able to.

You might see an error code (error 5 is "ACCESS_DENIED", you'll see it a lot). Or you might see a status 500 message because of an exception in the server. Or the server may just crash (hopefully not so often anymore...). I'm making it more resilient, but there are still bugs. Please report any previously-unreported issues you find, including how to reproduce them, and I'll fix them if possible.

Also feel free to request features or changes; I'll implement them if reasonably possible. The app is a mixture of C++ and C# code; I could probably have done it all in one or the other but wanted to have a C++ component in case I ran into something that wasn't available in C#, and although it probably would have saved some time, I decided that hacking up a web server in C++ was maybe not the best idea.

The source code is on Codeplex, at the following projects: https://wp8webserver.codeplex.com/ for the server and the app (C#) and https://wp8nativeaccess.codeplex.com/ for the native access wrappers (C++). You may have to fix up the reference paths to get the C# component to see the C++ component correctly. The code is reasonably well documented, but let me know if you have any questions. Permission to re-use the code or components is granted under the MS-PL (Microsoft Permissive License) as posted on Codeplex.

Go forth and find cool stuff!

Version history:
0.2.0: Initial release, FS only, 920 downloads (source: 652 downloads)
0.3.2: initial registry, HTTP server and web app encapsulation, source on Codeplex, 225 downloads
0.3.3: bugfixes, 454 downloads
0.4.2: basic registry values display, 86 downloads
0.4.3: bugfixes, 326 downloads
0.4.6: multistring registry values, bugfixes, updated libraries, first AllCapabilities version (950 downloads), 453 downloads
25 Oct 2013 - 0.4.8: binary and long registry values, formatting and bugfixes, 451 downloads AllCaps, 201 normal
22 Dec 2013 - 0.4.9: all registry value types, better threading, proper resume, remembers port, 97 downloads AllCaps, 53 normal
24 Dec 2013 - 0.5.0: background operation using Location APIs. Downloads: 1011 AllCaps, 963 Normal
20 Jul 2014 - 0.5.1: More capabilities, better navigation. Downloads: 108 AllCaps, 61 normal
07 Aug 2014 - 0.5.3: .REG export, better traversal, bugfixes.
Win8/Windows RT projects:
List of desktop apps for hacked RT devices

WP8 projects:
Native Access WebServer and Libraries
WP8 Interop Unlocks
Storage Cleanup tool

WP7 projects:
XapHandler, Root Webserver, OEM Marketplace XAPs, Bookmarklets collection (Find On Page), Interop-unlock hacks.


Do not private message me with questions that should have been posted on the forum! Not only are you wasting your time - I'm not going to bother writing an answer to such a question for only one person - but I will probably block you from PMing me in the future as well.
The Following 24 Users Say Thank You to GoodDayToDie For This Useful Post: [ Click to Expand ]
 
GoodDayToDie
Old
(Last edited by GoodDayToDie; 22nd December 2013 at 11:16 AM.)
#2  
Recognized Developer - OP
Thanks Meter 2678
Posts: 5,627
Join Date: Jan 2011
Location: Seattle
I'm going to use this space to mention something that's pretty cool:
J. Arturo of http://www.komodosoft.net is using a modified version of the HTTP server that powers this app in the ShareFolder app (http://www.windowsphone.com/s?appid=...a-8a2933a8bdb4) to support opening video files directly from Windows network shares! This was done to work around a limitation of the WP8 media control: it can only source from an isolated storage file or a HTTP URL. By running a server in the background and streaming the video file through it, and pointing the video player control at the localhost URL, it becomes possible to play the file on the phone without first copying it to the app's isolated storage. A very cool way to solve the problem! Also, reviewing the changes that were made to the network code of the server pointed me toward those threading fixes I made that have hopefully much improved version 0.4.9.
Please note that the updated version of ShareFolder with this feature may not yet be available, although it should be soon. It is a commercial (paid) app, but the author sought and received permission to use my code (although the license does not require such permission be received).
Win8/Windows RT projects:
List of desktop apps for hacked RT devices

WP8 projects:
Native Access WebServer and Libraries
WP8 Interop Unlocks
Storage Cleanup tool

WP7 projects:
XapHandler, Root Webserver, OEM Marketplace XAPs, Bookmarklets collection (Find On Page), Interop-unlock hacks.


Do not private message me with questions that should have been posted on the forum! Not only are you wasting your time - I'm not going to bother writing an answer to such a question for only one person - but I will probably block you from PMing me in the future as well.
The Following 4 Users Say Thank You to GoodDayToDie For This Useful Post: [ Click to Expand ]
 
mcosmin222
Old
#3  
Senior Member
Thanks Meter 206
Posts: 852
Join Date: May 2012
What exactly is the problem with sockets? I am battling myself with sockets atm too, maybe we can share knowledge?
 
GoodDayToDie
Old
#4  
Recognized Developer - OP
Thanks Meter 2678
Posts: 5,627
Join Date: Jan 2011
Location: Seattle
Strictly speaking, the problem was with the phone's limited subset of the Sockets API forcing me to access it through functions I wouldn't normally use (asynchronous everything, SocketAsyncEventArgs and lambdas and AutoResetEvents and so on everywhere...) but I've got a pretty good handle on it now, at least for the System.Net.Sockets.Socket and its friends. The new .NET 4.x ones (using the async keyword and all) are in a different namespace; I didn't mess with them. They are more abstracted from the Bekeley sockets interface that I'm used to from C, but they are also (supposedly) more user-friendly, especially if you don't feel like writing all your own thread management code (and in fairness, I should re-write the webserver's threading to use threadpools; they're better for this type of work).

If you want to ask questions about the topic, I suggest starting a new thread (possibly in the Q&A subforum, although it's also dev related...) and I'll answer if I can.
Win8/Windows RT projects:
List of desktop apps for hacked RT devices

WP8 projects:
Native Access WebServer and Libraries
WP8 Interop Unlocks
Storage Cleanup tool

WP7 projects:
XapHandler, Root Webserver, OEM Marketplace XAPs, Bookmarklets collection (Find On Page), Interop-unlock hacks.


Do not private message me with questions that should have been posted on the forum! Not only are you wasting your time - I'm not going to bother writing an answer to such a question for only one person - but I will probably block you from PMing me in the future as well.
The Following User Says Thank You to GoodDayToDie For This Useful Post: [ Click to Expand ]
 
sensboston
Old
#5  
Recognized Developer
Thanks Meter 419
Posts: 1,478
Join Date: Nov 2009
Location: Boston, MA

 
DONATE TO ME
GoodDayToDie, just an idea: how about sharing your source code via CodePlex or GitHub?
The Following 2 Users Say Thank You to sensboston For This Useful Post: [ Click to Expand ]
 
snickler
Old
#6  
snickler's Avatar
Forum Moderator / Recognized Developer
Thanks Meter 475
Posts: 815
Join Date: Aug 2010
Location: Wheeling, WV

 
DONATE TO ME
Oh man, this is pretty nice! GoodDayToDie does it again!
My Apps:
R1ng3d | CloudMuzik V1.5 Now in the MarketPlace for both WP7 and WP8
My Projects and Contributions:
WP8 Registry Tools | Async Wrapper for WP7 Root Tools SDK
My Phones:
Lumia 1520 - (8.1) / Lumia 920 - (8.1) / Focus v1.3 (7.8 via Dynamics ROM)
Contact
twitter: @sinclairinator | fb for: CloudMuzik | Skype: jsinnie

 
snickler
Old
(Last edited by snickler; 9th July 2013 at 07:22 PM.)
#7  
snickler's Avatar
Forum Moderator / Recognized Developer
Thanks Meter 475
Posts: 815
Join Date: Aug 2010
Location: Wheeling, WV

 
DONATE TO ME
So far, I can read \Windows, the current install folder which you access just by typing "." with no quotes and the current application folder by typing ".." I can access the .dlls, .winmd and AppManifest.xml from the current install, but from everywhere else, it goes boom. This is a great step towards something awesome though!

EDIT:

I was wrong. For some reason, when you click on a folder it's trying to "download" it, rather than chdir. I can get pretty far into the Windows directory.

THAT's what you meant by "Click on a file (note: there's no current way to tell the difference between files and folders) to download it.

You might see an error code (error 5 is "ACCESS_DENIED", you'll see it a lot). Or you might see a status 500 message because of an exception in the server. It's getting a lot more resilient but there are surely still some bugs. ".


If you see a folder, just type the full path to it instead of clicking on it and you will be able to read the contents.

ANOTHER EDIT:

I just found a file inside of the \Windows\System32 directory named [guid].devicemetadata-ms (It's easier to just search for "devicemetadata-ms"). It's a cab file with some metadata about WP8 with a sign.cat and packagesign.cat file in the archive. I don't know what these files could potentially be useful for.
My Apps:
R1ng3d | CloudMuzik V1.5 Now in the MarketPlace for both WP7 and WP8
My Projects and Contributions:
WP8 Registry Tools | Async Wrapper for WP7 Root Tools SDK
My Phones:
Lumia 1520 - (8.1) / Lumia 920 - (8.1) / Focus v1.3 (7.8 via Dynamics ROM)
Contact
twitter: @sinclairinator | fb for: CloudMuzik | Skype: jsinnie

 
GoodDayToDie
Old
(Last edited by GoodDayToDie; 9th July 2013 at 07:39 PM.)
#8  
Recognized Developer - OP
Thanks Meter 2678
Posts: 5,627
Join Date: Jan 2011
Location: Seattle
New version in a day or two (busy tonight). Features I plan to implement (not necessarily in the next version or at any particular time):
File upload (IsoStore and, of all crazy things, install directory are writable. I think I'll put a flag on each FS page that says whether the current dir is writable...).
File deletion (where possible, of course).
File and Directory distinction in the listing (clicking a dir should open it, not error out).
Filesystem index page with links to folders that can be accessed successfully (since the root isn't readable).
Some more file info (size, probably attributes, possibly permissions).
Possibly an option to preview a file (as plain text) without downloading it.
Some kind of background mode (the server uses minimal resources when not actively servicing a request, so I'll see if I can get it to work in the background, perhaps by abusing the music transfer agent...)
Some kind of offline mode (at least basic file browsing within the app, as an alternative to using the web interface, though I might just make a second app for that).
Source code changes: separate the server code from the webapp / phone app code (move it into its own project).
Source code changes: move to a hosted version control service, probably CodePlex (good suggestion sensboston).
Maybe add an icon and such...

Any other suggestions?

I also want to try experimenting with various non-standard capabilities and see if I can get access to more of the system . I've already added the ability to access removable storage, but I've also found a bunch of really weird and frequently undocumented capabilities in the OS's policy configuration files, and I need to look into those... The interesting (and possibly the uninteresting) ones are probably blocked for unsigned sideloaded apps, but it's worth checking on anyhow.
Win8/Windows RT projects:
List of desktop apps for hacked RT devices

WP8 projects:
Native Access WebServer and Libraries
WP8 Interop Unlocks
Storage Cleanup tool

WP7 projects:
XapHandler, Root Webserver, OEM Marketplace XAPs, Bookmarklets collection (Find On Page), Interop-unlock hacks.


Do not private message me with questions that should have been posted on the forum! Not only are you wasting your time - I'm not going to bother writing an answer to such a question for only one person - but I will probably block you from PMing me in the future as well.
The Following User Says Thank You to GoodDayToDie For This Useful Post: [ Click to Expand ]
 
GoodDayToDie
Old
#9  
Recognized Developer - OP
Thanks Meter 2678
Posts: 5,627
Join Date: Jan 2011
Location: Seattle
Yeah sorry, I should have been more explicit about clicking on dirs. not working in 0.2.0. Also, it's "unofficial" but if you check the URL bar you'll see a URL parameter called something like "pattern" (by default, it's *) and if you change that, you can filter the results. For example, "foo*.exe" (note: no quotes!) will search for EXE files whose names start with "foo". Among other uses, this makes it a lot faster to load large dirs like System32. This will be added to the UI at some point. Also note that URL decoding is applied correctly to querystring parameters (Probably already noticed with the path sometimes written using %5C for \) so you can add special characters that way if needed, though currently any of them but \ will probably just cause an exception.
...
Actually, does this filesystem support Alternate Data Streams? If so, you should be able to download them by appending a : and the ADS name to the filename in the download URL...
Win8/Windows RT projects:
List of desktop apps for hacked RT devices

WP8 projects:
Native Access WebServer and Libraries
WP8 Interop Unlocks
Storage Cleanup tool

WP7 projects:
XapHandler, Root Webserver, OEM Marketplace XAPs, Bookmarklets collection (Find On Page), Interop-unlock hacks.


Do not private message me with questions that should have been posted on the forum! Not only are you wasting your time - I'm not going to bother writing an answer to such a question for only one person - but I will probably block you from PMing me in the future as well.
The Following 2 Users Say Thank You to GoodDayToDie For This Useful Post: [ Click to Expand ]
 
GoodDayToDie
Old
#10  
Recognized Developer - OP
Thanks Meter 2678
Posts: 5,627
Join Date: Jan 2011
Location: Seattle
OK, so that was a new version in five days. Sorry, stuff takes time.
The source code is now on Codeplex. The native access portion is at https://wp8nativeaccess.codeplex.com/, and the web server portion is at https://wp8webserver.codeplex.com/. Both are licensed MS-PL and use Git for version control. The full XAP is also available for download from the Webserver project on Codeplex.
Win8/Windows RT projects:
List of desktop apps for hacked RT devices

WP8 projects:
Native Access WebServer and Libraries
WP8 Interop Unlocks
Storage Cleanup tool

WP7 projects:
XapHandler, Root Webserver, OEM Marketplace XAPs, Bookmarklets collection (Find On Page), Interop-unlock hacks.


Do not private message me with questions that should have been posted on the forum! Not only are you wasting your time - I'm not going to bother writing an answer to such a question for only one person - but I will probably block you from PMing me in the future as well.

The Following 2 Users Say Thank You to GoodDayToDie For This Useful Post: [ Click to Expand ]
Tags
webserver, xap
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes