News for hackers. Stuff that matters.
Re:Show HN: This website moves your mouse cursor by brundolf on Friday April 02, 2021 @01:22PM (#26673563)
It's a fun trick, but to reassure anyone who's panicking right now, it's not actually moving your cursor

It's hiding your cursor while it's over the site, rendering an <img> of a mouse cursor at its location, and then moving that around a) when you move your real cursor, and b) with random perturbations

Note to the author: the illusion would be even better if you used the user-agent to render a system-accurate mouse cursor ;) (on macOS the real cursor is black and the fake one is white)

Re:Show HN: This website moves your mouse cursor by baobabKoodaa on Friday April 02, 2021 @01:54PM (#26673905)
> Note to the author: the illusion would be even better if you used the user-agent to render a system-accurate mouse cursor ;) (on macOS the real cursor is black and the fake one is white)

You're right, it would make the illusion better. I developed this on Ubuntu where the default cursor is black, and I did consider doing this. Eventually decided to just use the default white cursor from Windows because it has better contrast on the dark color scheme. I guess I could set up 3 different color schemes for 3 different cursors for Mac, Linux, Windows, but it may be a bit too much work. I think most people who notice the cursor is different will just think "oh, this website uses a custom cursor", they won't necessarily realize that it's just an image.

Re:Show HN: This website moves your mouse cursor by tgsovlerkhgsel on Friday April 02, 2021 @08:07PM (#26677184)
It's definitely what tipped me off. With an accurate cursor, I might have been confused into wondering how it was done.

With the Pointer Lock API, you can actually take the user's cursor https://developer.mozilla.org/en-US/docs/Web/API/Pointer_Loc... (but the browser will show a notice).

Re:Show HN: This website moves your mouse cursor by Waterluvian on Friday April 02, 2021 @02:27PM (#26674288)
I'm on 18.04 and my cursor is white (and much smaller than the one on the site). I never realised Ubuntu had a black cursor option.

I think you could make these changes, but I think that's if you want to have fun doing it. The diminishing returns are tiny and the gag lands well.

Re:Show HN: This website moves your mouse cursor by brundolf on Friday April 02, 2021 @02:35PM (#26674391)
You're probably on a different desktop environment (Gnome, KDE, etc)
Re:Show HN: This website moves your mouse cursor by modeless on Friday April 02, 2021 @02:17PM (#26674159)
Even better would be to use the fullscreen api and mouse capture api to trap the mouse for real. Then you could render fake browser UI and do whatever you want when people try to click on it. If you really wanted to mess with people.
Re:Show HN: This website moves your mouse cursor by baobabKoodaa on Friday April 02, 2021 @02:20PM (#26674201)
If you use the fullscreen api or the pointer lock api, Chrome will render a popup that says "press ESC to..." Without that it would be sick!
Re:Show HN: This website moves your mouse cursor by modeless on Friday April 02, 2021 @02:22PM (#26674229)
Yeah but I bet at least half of people wouldn't notice, especially if you put something interesting on the other side of the screen for a second. Or you could render a bunch of overlapping fake warnings all over the screen, making it difficult to find the real one. Or you could put an exit fullscreen button and pretend to exit fullscreen when clicked, but you're actually still in fullscreen. Etc. I should probably stop giving the malware guys ideas...
Re:Show HN: This website moves your mouse cursor by juotlrjrb on Friday April 02, 2021 @07:35PM (#26677010)
Ctrl+W... Alt+F4...
Re:Show HN: This website moves your mouse cursor by vladvasiliu on Friday April 02, 2021 @01:26PM (#26673608)
> Note to the author: the illusion would be even better if you used the user-agent to render a system-accurate mouse cursor ;) (on macOS the real cursor is black and the fake one is white)

I've already seen sites that change the cursor's appearance, so I wasn't particularly "shocked" by that (I'm on a Mac).

However, what should improve the illusion would be to not move the cursor outside of the view area.

Re:Show HN: This website moves your mouse cursor by tyingq on Friday April 02, 2021 @02:23PM (#26674231)
Pointer lock does that, though I'm not sure what all browsers support it. Chrome/Desktop does:

https://mdn.github.io/dom-examples/pointer-lock/

It's a bit odd to me that it doesn't ask for any kind of permission on Chrome, just that a user click initiates it. It does briefly pop a hint that "<esc>" will release the mouse.

Re:Show HN: This website moves your mouse cursor by baobabKoodaa on Friday April 02, 2021 @03:12PM (#26674869)
Thanks for the feedback! The behavior around the edges should be improved now.
Re:Show HN: This website moves your mouse cursor by noobermin on Friday April 02, 2021 @03:05PM (#26674792)
I mean it was obvious by looking at the inspector if you have firefox. It's funny, I was able to "click" the how does it work button even though it makes it look like you can't mouseover it.

Also, kind of obvious given I use a gtk+3 dark theme and the mouse they use is white.

Re:Show HN: This website moves your mouse cursor by brundolf on Friday April 02, 2021 @04:36PM (#26675704)
Not everyone here is a web dev who's familiar with the inspector :)

With the genuine browser security concerns that do exist out there (and the often-exaggerated narrative around the degree of the problem), it's worth being explicit that this is not actually a real one

Re:Show HN: This website moves your mouse cursor by minikites on Friday April 02, 2021 @03:20PM (#26674963)
I used Mac OS for decades before switching, but I changed my Windows cursor to black because I'm used to it and I genuinely think it makes more sense with most backgrounds being light colors.
Re:Show HN: This website moves your mouse cursor by Blikkentrekker on Friday April 02, 2021 @10:56PM (#26678084)
I'm not sure what the panicking would be about being able to move the cursor inside the website.

I had assumed there would simply be Javascript calls for this. — how is it a problem that this be possible? that it can make one click on links that can be activated with Javascript on their own already?

Of course it could move one's cursor outside of it's own rendered page that would be problematic, but this trick cannot simulate that either.

Re:Show HN: This website moves your mouse cursor by baobabKoodaa on Saturday April 03, 2021 @04:52AM (#26679378)
There are no web apis to move a cursor within a web page. That means if you see a website moving your cursor, you see a website doing something it's not supposed to be able to do, and there's no reason to assume that that ability would be limited to the browser window or merely one tab in the browser. (Of course this website does not move your cursor.)
Re:Show HN: This website moves your mouse cursor by Blikkentrekker on Saturday April 03, 2021 @01:12PM (#26682759)
It's extremely easy to check because the effect stops outside of the website window itself or when the tab be switched?

And even if there is no a.p.i., when a website does it via some creative hack then one can assume the hack is most likely to work inside it's own window only.

And finally, how would the average layman no there is no such a.p.i.? even the expert could not be sure it wasn't added yesterday.

I really cannot see why the first response would be to panic and think the website somehow found a way to tell the web browser to make X11 calls to move the cursor, which is quite unlikely; the first response would be that there is an a.p.i. to move the cursor inside of it's own window, which is harmless, and after that that there is a creative hack to simulate it, and again, it's very easy to verify whether the cursor can be moved by the website once it leaves the browser window, and it cannot.

Re:Show HN: This website moves your mouse cursor by baobabKoodaa on Saturday April 03, 2021 @03:53PM (#26684165)
From what I can gather, April 1st is not your favorite day of the year.
Re:Show HN: This website moves your mouse cursor by xdrosenheim on Saturday April 03, 2021 @08:45AM (#26680611)
And the fact that it draws a mouse on mobile-devices.
Re:Show HN: This website moves your mouse cursor by throwaway_porn on Friday April 02, 2021 @02:31PM (#26674334)
But you should still panic a little bit because this technique can be used for https://en.wikipedia.org/wiki/Clickjacking
Re:Show HN: This website moves your mouse cursor by brundolf on Friday April 02, 2021 @04:34PM (#26675670)
The most it could do is fool you into thinking your cursor is somewhere else within the same web page, which the malicious dev in this case would already have total control over. If they wanted to fool you into clicking something, they'd have an easier time just mis-labeling the button
Re:Show HN: This website moves your mouse cursor by lazaroclapp on Friday April 02, 2021 @11:36PM (#26678233)
Since this can make you think your cursor is in a different position in the page than it actually is, couldn't it potentially be used to mislead you to click outside the page as well? Possibly not into browser chrome[1], but what about on a iframe?

Place button A the user wants to interact with at position (X,Y), place iframe button B at position (X+W,Y), with as little a border as possible with the rest of the page, then offset fake cursor by -W. User will try to mouse over button A, mistakenly mouse over button B, and click it in the time it takes to register that the mouse pointer just jumped from the edge of one button to the edge of the other...

[1] Though I can see the trick below maybe working for some browser's permission request "tooltip" UIs...