Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@ There have been a number of Cloudflare solvers developed:

### Fortified Headless Browsers <a href="#option-4-scrape-with-fortified-headless-browsers" id="option-4-scrape-with-fortified-headless-browsers"></a>

Use a headless browser that isn't deetcted as an automated browser (you might need to customize it for that). Some options are:
Use a headless browser that isn't detected as an automated browser (you might need to customize it for that). Some options are:

- **Puppeteer:** The [stealth plugin](https://github.com/berstend/puppeteer-extra/tree/master/packages/puppeteer-extra-plugin-stealth) for [puppeteer](https://github.com/puppeteer/puppeteer).
- **Playwright:** The [stealth plugin](https://www.npmjs.com/package/playwright-stealth) is coming to Playwright soon. Follow developments [here](https://github.com/berstend/puppeteer-extra/issues/454) and [here](https://github.com/berstend/puppeteer-extra/tree/master/packages/playwright-extra).
- **Selenium:** The [undetected-chromedriver](https://github.com/ultrafunkamsterdam/undetected-chromedriver) an optimized Selenium Chromedriver patch.

- **Selenium:** [SeleniumBase](https://github.com/seleniumbase/SeleniumBase) is a modern browser automation framework featuring built-in stealth capabilities. It offers two modes: **UC Mode**, an optimized Selenium ChromeDriver patch based on [undetected-chromedriver](https://github.com/ultrafunkamsterdam/undetected-chromedriver), and **CDP Mode**, which can bypass bot detection, solve CAPTCHAs, and leverage advanced methods from the Chrome DevTools Protocol.
### Smart Proxy With Cloudflare Built-In Bypass <a href="#option-5-smart-proxy-with-cloudflare-built-in-bypass" id="option-5-smart-proxy-with-cloudflare-built-in-bypass"></a>

**Smart proxies** proxies are continuously updated by specialized companies, aiming to outmaneuver Cloudflare's security measures (as thats their business).
Expand Down
50 changes: 50 additions & 0 deletions src/todo/rust-basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,28 @@

{{#include ../banners/hacktricks-training.md}}

### Ownership of variables

Memory is managed through a system of ownership with the following rules that the compiler checks at compile time:

1. Each value in Rust has a variable that's called its owner.
2. There can only be one owner at a time.
3. When the owner goes out of scope, the value will be dropped.

```rust
fn main() {
let student_age: u32 = 20;
{ // Scope of a variable is within the block it is declared in, which is denoted by brackets
let teacher_age: u32 = 41;
println!("The student is {} and teacher is {}", student_age, teacher_age);
} // when an owning variable goes out of scope, it will be dropped

// println!("the teacher is {}", teacher_age); // this will not work as teacher_age has been dropped
}
```



### Generic Types

Create a struct where 1 of their values could be any type
Expand Down Expand Up @@ -34,6 +56,24 @@ pub enum Option<T> {

You can use functions such as `is_some()` or `is_none()` to check the value of the Option.


### Result, Ok & Err

Used for returning and propagating errors

```rust
pub enum Result<T, E> {
Ok(T),
Err(E),
}
```

You can use functions such as `is_ok()` or `is_err()` to check the value of the result

The `Option` enum should be used in situations where a value might not exist (be `None`).
The `Result` enum should be used in situations where you do something that might go wrong


### Macros

Macros are more powerful than functions because they expand to produce more code than the code you’ve written manually. For example, a function signature must declare the number and type of parameters the function has. Macros, on the other hand, can take a variable number of parameters: we can call `println!("hello")` with one argument or `println!("hello {}", name)` with two arguments. Also, macros are expanded before the compiler interprets the meaning of the code, so a macro can, for example, implement a trait on a given type. A function can’t, because it gets called at runtime and a trait needs to be implemented at compile time.
Expand Down Expand Up @@ -363,6 +403,16 @@ Integrate it in CI and fail on `--deny warnings`.

`cargo deny check advisories` offers similar functionality plus licence and ban-list checks.

#### Code coverage with cargo-tarpaulin

`cargo tarpaulin` is a code coverage reporting tool for the Cargo build system

```bash
cargo binstall cargo-tarpaulin
cargo tarpaulin # no options are required, if no root directory is defined Tarpaulin will run in the current working directory.
```
On Linux, Tarpaulin's default tracing backend is still Ptrace and will only work on x86_64 processors. This can be changed to the llvm coverage instrumentation with `--engine llvm`. For Mac and Windows, this is the default collection method.

#### Supply-chain verification with cargo-vet (2024)

`cargo vet` records a review hash for every crate you import and prevents unnoticed upgrades:
Expand Down
Loading