An awesome blog about software development and network security.

Close the VM.
Edit the .vmx file and add this config:

1
2
3
mouse.vusb.enable = "TRUE"
mouse.vusb.useBasicMouse = "FALSE"
usb.generic.allowHID = "TRUE"

Save the .vmx file.
Start the VM and you can see that you can use the mouse side buttons to move forward and backward on the web page.

Read More

Widgets are a new feature introduced by Microsoft in Windows 11.
Currently, the news and interest modules that are enabled by default in widgets provide various kinds of information.

1
winget uninstall MicrosoftWindows.Client.WebExperience_cw5n1h2txyewy

For each new Windows 11 computer, I strongly recommand this command to improve the performance a lot.

Read More

Personal note editing needs

Core requirements:

  • Edit and save content in markdown format, which makes the format simple, easy to use, open, and easy to migrate
  • Support WYSIWYG mode when editing, similar to Typora
  • Open source, thus keeping content safe and free
  • Support offline use, data can be stored locally, or stored in third-party channels such as Google Drive, Github repository
  • Support direct copying of pictures and text on web pages and paste them directly
  • Open the folder and display the file directory structure, which is convenient for placing and organizing notes according to the file directory from the sidebar
  • Supports the creation of internal links between markdown files, which can be easily jumped
  • Supports relationship graphs showing internal links in documents

Optional Requirements

  • Supports loading plugins to extend functionality
  • Open the online version editor directly from the web browser, call the file API to open the local folder for editing, therefore even chromebook can use it

Software solutions

  • Logseq : Not perfect, but currently the most recommended
  • Advantages:
    • Open source, most functions are as easy to use as Obsidian, such as beautiful appearance, local data storage, support for bidirectional links and relationship graphs
    • There is a web version, you can directly open the local folder
  • Shortcomings:
    • The directory structure browsing is not supported, and all the notes are mixed together and it is not easy to classify. Solution: If you find a way to write a “navigation document”, similar to the Yellow Pages, and then bookmark it, and add a link to the Yellow Pages every time you add a sub-document, it may also be a convenient way to find files by category. This is still not convenient like a directory, but it can be adapted.
    • Does not support the rendering the md standard checkbox.
  • Notion: It is basically free and easy to use, but there is no offline version, you cannot save data locally and synchronize data in your own way, which brings hidden dangers in data security and privacy, so you cannot use it with confidence. However, it supports the use of online real-time collaboration scenarios and can be used on projects, but is not suitable for storing personal core data.
  • Obsidian: It is completely free, easy to use, and supports all requirements except open source, but it is not open source. There is currently no better option for personal use.
  • VSCode+Office Viewer plugin (based on vditor): open source, md editing function is very powerful, and there is a toolbar. But bidirectional links and relational graphs are not supported. It can be said to be a good md editor, but not a very good note editor. And this plugin does not support running in the VSCode web.
Read More

Today I wanted to practice on Leetcode, and then I opened https://github.com/phodal/2md to save the problem to local.
Because I found that there were some small problems with this tool, I forked a copy and fixed some errors that it would generate when converting the content of the leetcode problem.
In this way, copy the problem of leetcode and paste it into my 2md, and then copy the converted markdown to save it locally.
Repo: https://github.com/immortalt/2md
The displayed format is correct, and the effect is much better.
The online address of my 2md: https://immortal-blog.github.io/tomd/

Read More

Sometimes the shared folder function of VMware Workstation may suddenly not work after rebooting.
There are several ways to fix it.

mount by a command

1
sudo vmhgfs-fuse .host:/ /mnt/hgfs -o subtype=vmhgfs,allow_other -o nonempty

This command means to mount all host shared folders to /mnt/hgfs, which is the default operation that VMware should have done automatically.
However, the folder would disappear after rebooting.

mount automatically

1
sudo nano /etc/fstab

We can edit the fstab file to write the auto-mount configuration. Just add one line:

1
.host:/ /mnt/hgfs fuse.vmhgfs-fuse allow_other,defaults 0 0
Read More

When dividing, be careful with large numbers

Sample: they should be different, but due to the float format, they become the same.

1
2
3
4
a = (1 - 500000000) / (1 - 499999999)
b = (500000000 - 1000000000) / (499999999 - 999999998)
print(a, b, a == b)
# 1.000000002 1.000000002 True

In this situation, we can just simply use Decimal.

1
2
3
4
5
from decimal import Decimal
a = Decimal(1 - 500000000) / Decimal(1 - 499999999)
b = Decimal(500000000 - 1000000000) / Decimal(499999999 - 999999998)
print(a, b, a == b)
# 1.000000002000000008000000032 1.000000002000000004000000008 False
Read More

Currently (2022-05-16), we cannot install and run VMWare Workstation 16.2.3 on Ubuntu Desktop 22.04 LTS.
You can installed it and see the icon, but when you try to open it, it would ask you to install some modules and would fail.

Solution

Here is a script that are verified by me that can solve the problem.

1
2
3
4
5
git clone https://github.com/mkubecek/vmware-host-modules
cd vmware-host-modules
git checkout workstation-16.2.3
sudo make ; sudo make install
sudo modprobe -a vmw_vmci vmmon vmnet

Then you may need to reboot the host system to make VM networks working.

Conclusion

Although Ubuntu 22.04 is a LTS version, it is not stable and compatible enough to deal with daily works currently. My advice is to use Ubuntu 20.04.

Read More

What are font ligatures?

image
It’s an interesting feature in fonts like JetBrains Mono.

I have enabled Jetbrains Mono, but why not see font ligatures?

I think VSCode or Word disables this feature by default, and we need to change font options to enable this feature.

VSCode

Open “Menu”-“Setting”, open “setting.json”, and change this option:

1
"editor.fontLigatures": true
Read More
post @ 2022-04-23

Symmetric encryption communication

The most straightforward way is that you can decide on an encryption key in reality and use symmetric encryption such as AES-256 to encrypt and decrypt all messages.
But it’s not convenient to exchange the key online. Because if you send the key using an unsafe channel that is being monitored, the attacker can also get the key and decrypt all your messages. The attacker can directly use passive attack (read-only, without any modification) to monitor the messages.
One way is to use asymmetric encryption communication.

Asymmetric encryption communication

The mechanism of asymmetric encryption can be that A and B each generate a set of public keys and private keys and then use the other one’s public key to encrypt the content and send it, and the other one can decrypt it with its private key after receiving it.
Therefore, even if the attacker gets A and B’s public keys, he cannot decrypt the messages because he needs to know the private key.
But it’s still not perfect.

MITM attack in asymmetric encryption communication

MITM means man-in-the-middle attack. Suppose you generate a public key and a private key for two clients, A and B, and then exchange the public keys of the two through a server C, and the server C is not secure. It is useless to monitor the public keys because only obtaining the public key cannot decrypt messages with the private key, so it cannot be monitored. But suppose B’s public key is replaced by C, and A uses this replaced public key C to encrypt messages. In that case, server C decrypts it with C’s private key, encrypts it with B’s public key, and B decrypts it with its private key. A and B have no sense, and C succeeds in a man-in-the-middle attack. Even if a secure key exchange technology such as the D-H key exchange method is used, the key exchange process can still be relayed by server C as a middleman.
The attacker cannot directly use passive attack to monitor the messages in asymmetric encryption communication. The attacker needs to manipulate and change the communication flow.

Read More

Sometimes we may find that a program is occupying a port, and we cannot use this port.
We can use two commands to solve this problem.

Find the program

1
2
netstat -anp | grep 4000
tcp6 0 0 :::4000 :::* LISTEN 81970/hexo

Here we can find the pid 81970 before the program name.

Kill the program

1
kill -9 81970

If the permissions are not enough, add sudo before the command.

Read More
⬆︎TOP