semvec/pypi-packages huggingface dataset:
padding-oracle 0.4.1
Threaded padding oracle automation.
Requires Python: >=3.10

# Padding Oracle Automation in Python

![Python Package Badge](https://github.com/djosix/padding_oracle.py/actions/workflows/python-package.yml/badge.svg)

This script automates padding oracle attacks in Python, offering efficient and threaded execution.

## Installation

You can install the script using one of these methods:

- **Via PyPI:**
  ```shell
  pip3 install -U padding_oracle
  ```

- **Directly from GitHub:**
  ```shell
  pip3 install -U git+https://github.com/djosix/padding_oracle.py.git
  ```

## Performance

The script's performance varies depending on the number of request threads. This was tested in a CTF web challenge:

| Request Threads | Time Taken  |
|-----------------|-------------|
| 1               | 17m 43s     |
| 4               | 5m 23s      |
| 16              | 1m 20s      |
| 64              | 56s         |

## Usage

### Decryption

When trying to decrypt a token like the one at `https://example.com/api/?token=M9I2K9mZxzRUvyMkFRebeQzrCaMta83eAE72lMxzg94%3D`, this script assumes that the token is vulnerable to a padding oracle attack.

```python
from padding_oracle import decrypt, base64_encode, base64_decode
import requests

sess = requests.Session()  # Uses connection pooling
url = 'https://example.com/api/'

def oracle(ciphertext: bytes):
    response = sess.get(url, params={'token': base64_encode(ciphertext)})
    if 'failed' in response.text:
        return False  # Token decryption failed
    elif 'success' in response.text:
        return True
    else:
        raise RuntimeError('Unexpected behavior')

ciphertext = base64_decode('M9I2K9mZxzRUvyMkFRebeQzrCaMta83eAE72lMxzg94=')
assert len(ciphertext) % 16 == 0

plaintext = decrypt(
    ciphertext,
    block_size=16,
    oracle=oracle,
    num_threads=16,
)
```

### Encryption

Below is an example demonstrating how to encrypt arbitrary bytes. For a detailed understanding of the process, please refer to [this Pull Request](https://github.com/djosix/padding_oracle.py/pull/4).

```python
from padding_oracle import encrypt

ciphertext = encrypt(
    b'YourTextHere', 
    block_size=16,
    oracle=oracle,
    num_threads=16,
)
```

### Customized Logging

Both `encrypt` and `decrypt` allow user to inject a custom logger:

- **Disable Logging:**
  ```python
  from padding_oracle import nop_logger

  plaintext = decrypt(
      ...
      logger=nop_logger,
  )
  ```

- **Selective Logging:**
  ```python
  def logger(kind: str, message: str):
      if kind in ('oracle_error', 'solve_block_error'):
          print(f'[{kind}] {message}')

  plaintext = decrypt(
      ...
      logger=logger,
  )
  ```

### Extras

The script also includes PHP-like encoding and decoding functions:

```python
from padding_oracle.encoding import urlencode, urldecode, base64_encode, base64_decode
```

### TODO

- [ ] Support more padding schemes

## License

This script is distributed under the MIT license.
bing-brush 0.1.2
One-line Image Generating Program Based on the Bing Image Createor (Powered by DALL·E 3)
Requires Python: >=3.8

<div align="center">
  <img width="200px" src="https://github.com/vra/bing_brush/blob/main/assets/logo.jpeg"/>
  
### One-line Image Generating Program Based on the Bing Image Createor (Powered by DALL·E 3)

</div>

---

Credit: The solution of invoking Bing Image Creator API is from <https://github.com/acheong08/BingImageCreator>.

## Installation
```bash
pip install bing_brush
```

### Obtain your cookie

The cookie of Bing.com is needed. You need to login to Bing.com first, then follow the steps below to write your cookie to a file (e.g., `cookie.txt`):

#### Step0:
Vist <https://www.bing.com/images/create>
<div align="center">
  <img width="500px" src="https://github.com/vra/bing_brush/blob/main/assets/step0.jpg"/>
</div>

#### Step1:
Press F12 to open dev tools, then refresh the web page to run all requests again:
<div align="center">
  <img width="500px" src="https://github.com/vra/bing_brush/blob/main/assets/step1.jpg"/>
</div>
Select any rquest with type of xhr, then click the head of the request


#### Step2:
In the detail of the request header, find the `Cookie` section, copy the value of it to your file (e.g., cookie.txt)
<div align="center">
  <img width="500px" src="https://github.com/vra/bing_brush/blob/main/assets/step2.jpg"/>
</div>
Then your cookie for Bing.com has successfully be stored.

## Usage
### CLI
```bash
# -c is short for --cookie, -p is short for --prompt
bing_brush -c cookie.txt -p 'a cute panda eating bamboos' -o output_folder
```
This command will generate 4 pictures located in `output_folder`, example outputs:
<div align="center">
  <img width="800px" src="https://github.com/vra/bing_brush/blob/main/assets/demo_outputs.png"/>
</div>

### Python API
```python
brush = BingBrush(cookie='/path/to/cookie.txt')
brush.process(prompt='a cute panda eating bamboos', out_folder='output_folder')
```


## TODO
+ [ ] unit test
+ [ ] support for obtaining cookie from os.env


## Logo
Logo of this project is generated by Bing Image, prompt:
> A minimalist logo vector image, square-shaped, with a magical brush implemented in Python language in the center, colorful, digitial art

## Contribution

##
meeseeks-singleton 0.4.4
A Singleton python project
Requires Python: >=3.8,<4.0

# A Singleton python project

![Alt text](https://ih1.redbubble.net/image.1140492877.4744/mp,504x516,gloss,f8f8f8,t-pad,600x600,f8f8f8.jpg "Title")


By CenturyBoys

Did you need help? Call meeseeks from a single box from anywhere

This is meeseeks a single class to do singletons. In the core meeseeks is a class decorator that allows you to have a global singleton scope or a specialized one, some configurations can be used to give more flexibility to your code.


# Scopes

Each class with his decorator has a specialized scope, that is otherwise you create meeseeks object (OnlyOne) and this object will have your configuration and singletons

### Specialized

```python
import meeseeks

@meeseeks.OnlyOne()
class A:
    def __int__(self, a):
        pass

a1a = A(10)
a1b = A(10)
a1c = A(20)

assert a1a == a1b == a1c
```

or

```python
import meeseeks

only_one = meeseeks.OnlyOne()

@only_one
class A:
    def __int__(self, a):
        pass

a1a = A(10)
a1b = A(10)
a1c = A(20)

assert a1a == a1b == a1c
```

On this example we register the class reference in the meeseeks class instance scope

# Configuration

We provide two configuration options:
- `tll: int` (time to live) in seconds. Setting a value greater than 0, the singleton reference will have a time to live in seconds (default 0). Obs: the expired time validation will be made only when you create a new instance of the registered class _ie_ your object will still be in memory
-  `by_args_hash: bool` ( a hash will be made of all args and kwargs ). Setting True, a singleton reference will be created for each arg + kwargs hash (default False). Obs:  The kwargs`s order doesn't have influence
        

### TTL 

```python
import meeseeks
import time

@meeseeks.OnlyOne(ttl=1)
class A:
    def __int__(self, *args, **kwargs):
        pass

a1a = A(1, var_a="a")
a1b = A(1, var_a="a")

time.sleep(1)

a1c = A(1, var_a="a")

assert a1a == a1b
assert a1b != a1c
```

In this example, we set the `ttl` to `1` second and validate if the first two calls result in the same object and after 1 second we validate if the object is different from the first two

### BY_ARGS_HASH


```python
import meeseeks
import time

@meeseeks.OnlyOne(by_args_hash=True)
class A:
    def __int__(self, *args, **kwargs):
        pass

a1a = A(1, var_a="a", var_b="b")
a1b = A(1, var_b="b", var_a="a")
a1c = A(10, var_b="b", var_a="a")



assert a1a == a1b
assert a1c != a1b
```
In this example, we set  `by_args_hash` variable to `True` and validate if the first two calls result in the same object despite the kwargs order being different. The last validation shows us that different args and kwargs result in different objects.
weather2 1.6.2
Access weather forecast


# weather - Access weather forecast
## Installation
```
pip install weather
```
## Usage
```python
import weather
forecast=weather.forecast()
forecast.today['6:00'].temp # Get temperature in current location at 6.00
```
### Different places
If you want to get forecast from different place, pass `forecast` an argument.
```python
import weather
forecast=weather.forecast('New York')
forecast.tommorow['11:00'].precip # Get precipitation in New York at 11.00
```
### Different sources
`weather` supports two weather sources:
1. [Yr.No](https://yr.no)
1. [7timer!](https://7timer.info)
If you want to get weather from different source, pass `forecast` argument called `source`.
```python
weather.forecast(service='yrno')
weather.forecast(service='7timer')
```
### Weather properties
<ol>
  <li>
    <p><code>wind</code>: Instance of <code>Wind()</code></p>
    Properties:
    <ol>
      <li>
        <p><code>speed</code>: Integer</p>
        Speed in m/s
      </li>
      <li>
        <p><code>direction</code>: Instance of <code>Direction()</code></p>
        Properties:
        <ol>
          <li>
            <p><code>angle</code>: Integer</p>
            Angle in degrees
          </li>
          <li>
            <p><code>direction</code>: String</p>
            Angle in compass point (<code>'N'</code>,<code>'NE'</code>,<code>'E'</code>,<code>'SE'</code>,<code>'S'</code>,<code>'SW'</code>,
            <code>'W'</code>, or <code>'NW'</code>)
          </li>
        </ol>
      </li>
    </ol>
  </li>
  <li>
    <p><code>temp</code>: Float/Integer</p>
      Temperature in °C or °F (not °K) (default °C, see 'Changing units')
  </li>
  <li>
    <p><code>humid</code> (<code>yr.no</code> only, other services will return <code>None</code>): Float/Integer</p>
      Humidity in %.
  </li>
  <li>
    <p><code>precip</code> (<code>7timer</code> will return <code>bool</code>): Float/Integer</p>
      Precipitation amount in milimeters
</ol>

### Changing units
```python
weather.forecast('New york', unit=weather.CELSIUS)#or weather.FAHRENHEIT
```
### CLI
Just run `weather`:
    ```[user@localhost ~] weather```
If you want to get all avaliable switches, use `weather -h`:

```python
usage: weather [-h] [--city CITY] [--country COUNTRY] [-d] [-s SERVICE]
                   [-u] [-a]

Python app for getting weather forecast

options:
  -h, --help            show this help message and exit
  --city CITY           City for forecast (if not passed, using current
                        location)
  --country COUNTRY     Country for forecast (see above)
  -d, --debug           Debug
  -s SERVICE, --service SERVICE
                        Service to use ("yrno" or "7timer"). Implied with
                        "average"(try to optimise the service)
  -u, --ugly            Toggle JSON output
  -a, --api             Just print the data (implies JSON output)

``` 
That says basically enough to use it.

### License

`weather` is licensed under *MIT license*