troll - Dave's Blog

Search
My timeline on Mastodon

Tiny browser features: JSBrowser zoom

2018 May 10, 3:49

JSBrowser is a basic browser built as a Win10 JavaScript UWP app around the WebView HTML element. Its fun and relatively simple to implement tiny browser features in JavaScript and in this post I'm implementing zoom.

My plan to implement zoom is to add a zoom slider to the settings div that controls the scale of the WebView element via CSS transform. My resulting zoom change is in git and you can try the whole thing out in my JSBrowser fork.

Slider

I can implement the zoom settings slider as a range type input HTML element. This conveniently provides me a min, max, and step property and suits exactly my purposes. I chose some values that I thought would be reasonable so the browser can scale between half to 3x by increments of one quarter. This is a tiny browser feature after all so there's no custom zoom entry.

<a><label for="webviewZoom">Zoom</label><input type="range" min="50" max="300" step="25" value="100" id="webviewZoom" /></a>

To let the user know this slider is for controlling zoom, I make a label HTML element that says Zoom. The label HTML element has a for attribute which takes the id of another HTML element. This lets the browser know what the label is labelling and lets the browser do things like when the label is clicked to put focus on the slider.

Scale

There are no explicit scale APIs for WebView so to change the size of the content in the WebView we use CSS.

        this.applyWebviewZoom = state => {
const minValue = this.webviewZoom.getAttribute("min");
const maxValue = this.webviewZoom.getAttribute("max");
const scaleValue = Math.max(Math.min(parseInt(this.webviewZoom.value, 10), maxValue), minValue) / 100;

// Use setAttribute so they all change together to avoid weird visual glitches
this.webview.setAttribute("style", [
["width", (100 / scaleValue) + "%"],
["height", "calc(" + (-40 / scaleValue) + "px + " + (100 / scaleValue) + "%)"],
["transform", "scale(" + scaleValue + ")"]
].map(pair => pair[0] + ": " + pair[1]).join("; "));
};

Because the user changes the scale at runtime I accordingly replace the static CSS for the WebView element with the script above to programmatically modify the style of the WebView. I change the style with one setAttribute call to do my best to avoid the browser performing unnecessary work or displaying the WebView in an intermediate and incomplete state. Applying the scale to the element is as simple as adding 'transform: scale(X)' but then there are two interesting problems.

The first is that the size of the WebView is also scaled not just the content within it. To keep the WebView the same effective size so that it still fits properly into our browser UI, we must compensate for the scale in the WebView width and height. Accordingly, you can see that we scale up by scaleValue and then in width and height we divide by the scaleValue.

transform-origin: 0% 0%;

The other issue is that by default the scale transform's origin is the center of the WebView element. This means when scaled up all sides of the WebView would expand out. But when modifying the width and height those apply relative to the upper left of the element so our inverse scale application to the width and height above aren't quite enough. We also have to change the origin of the scale transform to match the origin of the changes to the width and height.

PermalinkCommentsbrowser css-transform javascript JS jsbrowser uwp webview win10

Tweet from Pwn All The Things

2016 Sep 6, 10:47
Oh My God. This report is such a troll. Hackers cleverly hid their searching of network shares using "SMB protocol"
PermalinkComments

Tweet from Johnny Xmas

2016 Jun 16, 1:30
::weeps uncontrollably::
PermalinkComments

Tweet from Jen Gentleman

2016 May 13, 3:51
You can use the curser controller just by flicking it 😉 📱 pic.twitter.com/Gl9FB5YAq6
PermalinkComments

Tweet from David_Risney

2015 Oct 14, 2:54
Thor's hammer = Microwave's electromagnet + Arduino + fingerprint scanner. Inventor trolls Venice Beach bystanders: http://www.cnet.com/news/engineer-builds-working-thors-hammer-only-he-can-lift/ …
PermalinkComments

Tweet from David_Risney

2015 Aug 13, 4:02
Watch GTA5 player's game get hacked by back rubbing, multiplying, exploding troll. https://www.youtube.com/watch?v=LMUe7qMxM1s …
PermalinkComments

Retweet of waxpancake

2015 Apr 2, 8:55
"But you're not you. You're your digital you. Virtually real, controlled by real you." https://www.youtube.com/watch?v=G9FGgwCQ22w … pic.twitter.com/JhhdPNMN4g
PermalinkComments

Tweet from David_Risney

2015 Feb 8, 11:17
Analysis of 2011 DARPA Challenge tracks down the trolls who destroyed their competitors crowd sourced solution. https://medium.com/backchannel/how-a-lone-hacker-shredded-the-myth-of-crowdsourcing-d9d0534f1731 …
PermalinkComments

Bank robbers use KVM switch and 3G router to steal money

2014 Apr 28, 10:01

Using social engineering to install a remote-controlled keyboard-video-mouse (KVM) switch on bank PCs, the gang managed to transfer millions to outside accounts in two separate jobs in April and July of 2013. They were caught attempting to rob a third bank in September.

PermalinkCommentstechnical bank-robbery

Xbox One Sign Out Trolling - YouTube

2014 Jan 8, 5:53PermalinkCommentsvideo game xbox voice security

theatlantic: Victorian Trolling: How Con Artists Spammed in a...

2013 Oct 29, 7:42


theatlantic:

Victorian Trolling: How Con Artists Spammed in a Time Before Email

The main difference between 21st-century scams and those of centuries past is one of delivery method.

Read more. [Image: Wikimedia Commons/Benjamin Breen]

PermalinkCommentshistory spam technical humor internet

Stripe CTF - XSS, CSRF (Levels 4 & 6)

2012 Sep 10, 4:43

Level 4 and level 6 of the Stripe CTF had solutions around XSS.

Level 4

Code

> Registered Users 

    <%@registered_users.each do |user| %>
    <%last_active = user[:last_active].strftime('%H:%M:%S UTC') %>
    <%if @trusts_me.include?(user[:username]) %>

  • <%= user[:username] %>
    (password: <%= user[:password] %>, last active <%= last_active %>)
  • Issue

    The level 4 web application lets you transfer karma to another user and in doing so you are also forced to expose your password to that user. The main user page displays a list of users who have transfered karma to you along with their password. The password is not HTML encoded so we can inject HTML into that user's browser. For instance, we could create an account with the following HTML as the password which will result in XSS with that HTML:

    
    
    This HTML runs script that uses jQuery to post to the transfer URI resulting in a transfer of karma from the attacked user to the attacker user, and also the attacked user's password.

    Notes

    Code review red flags in this case included lack of encoding when using user controlled content to create HTML content, storing passwords in plain text in the database, and displaying passwords generally. By design the web app shows users passwords which is a very bad idea.

    Level 6

    Code

    
    

    ...

    def self.safe_insert(table, key_values)
    key_values.each do |key, value|
    # Just in case people try to exfiltrate
    # level07-password-holder's password
    if value.kind_of?(String) &&
    (value.include?('"') || value.include?("'"))
    raise "Value has unsafe characters"
    end
    end

    conn[table].insert(key_values)
    end

    Issue

    This web app does a much better job than the level 4 app with HTML injection. They use encoding whenever creating HTML using user controlled data, however they don't use encoding when injecting JSON data into script (see post_data initialization above). This JSON data is the last five most recent messages sent on the app so we get to inject script directly. However, the system also ensures that no strings we write contains single or double quotes so we can't get out of the string in the JSON data directly. As it turns out, HTML lets you jump out of a script block using no matter where you are in script. For instance, in the middle of a value in some JSON data we can jump out of script. But we still want to run script, so we can jump right back in. So the frame so far for the message we're going to post is the following:

    
    
    
    
PermalinkCommentscsrf encoding html internet javascript percent-encoding script security stripe-ctf technical web xss

Stripe CTF - Input validation (Levels 1 & 2)

2012 Sep 6, 5:00

Stripe's web security CTF's Level 1 and level 2 of the Stripe CTF had issues with missing input validation solutions described below.

Level 1

Code

          $filename = 'secret-combination.txt';
extract($_GET);
if (isset($attempt)) {
$combination = trim(file_get_contents($filename));
if ($attempt === $combination) {

Issue

The issue here is the usage of the extract php method which extracts name value pairs from the map input parameter and creates corresponding local variables. However this code uses $_GET which contains a map of name value pairs passed in the query of the URI. The expected behavior is to get an attempt variable out, but since no input validation is done I can provide a filename variable and overwrite the value of $filename. Providing an empty string gives an empty string $combination which I can match with an empty string $attempt. So without knowing the combination I can get past the combination check.

Notes

Code review red flag in this case was the direct use of $_GET with no validation. Instead of using extract the developer could try to extract specifically the attempt variable manually without using extract.

Level 2

Code

    $dest_dir = "uploads/";
$dest = $dest_dir . basename($_FILES["dispic"]["name"]);
$src = $_FILES["dispic"]["tmp_name"];
if (move_uploaded_file($src, $dest)) {
$_SESSION["dispic_url"] = $dest;
chmod($dest, 0644);
echo "

Successfully uploaded your display picture.

";
}

Issue

This code accepts POST uploads of images but with no validation to ensure it is not an arbitrary file. And even though it uses chmod to ensure the file is not executable, things like PHP don't require a file to be executable in order to run them. Accordingly, one can upload a PHP script, then navigate to that script to run it. My PHP script dumped out the contents of the file we're interested in for this level:

Notes

Code review red flags include manual file management, chmod, and use of file and filename inputs without any kind of validation. If this code controlled the filename and ensured that the extension was one of a set of image extensions, this would solve this issue. Due to browser mime sniffing its additionally a good idea to serve a content-type that starts with "image/" for these uploads to ensure browsers treat these as images and not sniff for script or HTML.

PermalinkCommentsinput-validation php security technical

paulscheer: Paul Scheer and Adam Scott trolling Comic...

2012 Jul 17, 3:48






paulscheer:

Paul Scheer and Adam Scott trolling Comic Con

Yup…This Happened!

And the video:

http://www.youtube.com/watch?v=B1lyRA8IRgQ#t=1m29s

PermalinkCommentshumor comic-con paul-scheer adam-scott

wired: cnet: Mp3 playing retainer transmits music through your...

2012 Jul 3, 2:31




wired:

cnet:

Mp3 playing retainer transmits music through your teeth:

Bone conduction audio, retainers, and shiny hip-hop teeth grills aren’t new inventions, but tech hacker Aisen Caro Chacin had the clever idea to put them all together.

The Play-A-Grill MP3 player prototype fits in your mouth like a retainer, shines on the outside like a precious metal rap grill, and plays music through bone conduction through your teeth.

Read more

Oh man, this would have made puberty just a touch cooler. Maybe. 

PermalinkCommentshumor mp3 tech

"A context mechanism for controlling caching of HTTP responses" - Yngve Pettersen

2012 Mar 7, 8:00PermalinkCommentstechnical http caching

draft-hammer-hostmeta-14 - Web Host Metadata

2011 Apr 17, 12:51"Web-based protocols often require the discovery of host policy or metadata, where "host" is not a single resource but the entity controlling the collection of resources identified by Uniform Resource Identifiers (URI) with a common URI host [RFC3986]."PermalinkCommentshost rfc reference metadata technical

Amazon Kindle: Most Highlighted Passages of All Time

2010 May 3, 7:27Amazon has the most highlighted passages of Kindle users. Of course Dan Brown is all over that. But in 94th place of most highlighted is a passage from the 'Kindle Shortcuts' book on how to highlight passages: "Go to top Notes and Clippings (Kindle 2) To create a highlight: use the 5-way controller to highlight the content you want to clip and then press the 5-way to save your selection... Highlighted by 319 Kindle users"PermalinkCommentshumor highlight amazon kindle technical meta

This is the title of a typical incendiary blog post - Coyote Crossing

2010 Jan 28, 2:32A typical blog post with typical blog post comments... "This comment gives a link to a YouTube video which is proffered as an excellent example of the thesis of the post, but, is actually only tangentially so at best."PermalinkCommentshumor blog web troll

Joho the Blog » Broadband. Trust them.

2009 Sep 25, 5:18"The closest the organization comes to stating its actual intent is in the wording of the print ad they’re running. Hmm. On the open medium of the Internet the organization hides its purpose, but in the controlled medium of print, they come close to stating it. How unexpected!"PermalinkCommentsnet-neutrality network-neutrality network internet broadband isp cable humor
Older Entries Creative Commons License Some rights reserved.