All Projects → rkm0959 → Inequality_Solving_with_CVP

rkm0959 / Inequality_Solving_with_CVP

Licence: other
CVP "trick" for CTF challenges

Programming Languages

Sage
50 projects
python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Inequality Solving with CVP

BerylEnigma
一个为渗透测试与CTF而制作的工具集,主要实现一些加解密的功能。
Stars: ✭ 329 (+344.59%)
Mutual labels:  ctf
CTF-Script-And-Template-Thrift-Shop
[180+ scripts] There are a few genuine gems in there. And a lot of spaghetti code. Most of these scripts were for solving CTF's. If you googles something for a CTF and landed here look at the scripts they're all fairly malleable. Sorry for the shitty naming conventions (not really). If you are a recruiter stop. I wont be able to rewrite half thi…
Stars: ✭ 38 (-48.65%)
Mutual labels:  ctf
Enum.py
A tool to enumerate network services
Stars: ✭ 23 (-68.92%)
Mutual labels:  ctf
fhq-server
This is an open source platform for competitions of computer security.
Stars: ✭ 33 (-55.41%)
Mutual labels:  ctf
ctf
CTF programs and writeups
Stars: ✭ 22 (-70.27%)
Mutual labels:  ctf
BinV
👓 Yet another binary vulnerbilities checker. An automated vulnerability scanner for ELF based on symbolic execution.
Stars: ✭ 25 (-66.22%)
Mutual labels:  ctf
winpwn
CTF windows pwntools
Stars: ✭ 137 (+85.14%)
Mutual labels:  ctf
HashExploit
HashExpoit is Great Tool For Cracking Hash
Stars: ✭ 17 (-77.03%)
Mutual labels:  ctf
robot hacking manual
Robot Hacking Manual (RHM). From robotics to cybersecurity. Papers, notes and writeups from a journey into robot cybersecurity.
Stars: ✭ 169 (+128.38%)
Mutual labels:  ctf
webcocktail
An automatic and lightweight web application scanning tool for CTF.
Stars: ✭ 28 (-62.16%)
Mutual labels:  ctf
spellbook
Framework for rapid development and reusable of security tools
Stars: ✭ 67 (-9.46%)
Mutual labels:  ctf
bento
Bento Toolkit is a minimal fedora-based container for penetration tests and CTF with the sweet addition of GUI applications.
Stars: ✭ 74 (+0%)
Mutual labels:  ctf
ctf writeups
No description or website provided.
Stars: ✭ 25 (-66.22%)
Mutual labels:  ctf
GitCTF
Git-based CTF
Stars: ✭ 53 (-28.38%)
Mutual labels:  ctf
How-to-Hack-Websites
開源的正體中文 Web Hacking 學習資源 - 程式安全 2021 Fall
Stars: ✭ 291 (+293.24%)
Mutual labels:  ctf
ructfe-2019
RuCTFE 2019. Developed with ♥ by HackerDom team
Stars: ✭ 24 (-67.57%)
Mutual labels:  ctf
watchman
AML/CTF/KYC/OFAC Search of global watchlist, sanctions, and politically exposed person (PEP)
Stars: ✭ 167 (+125.68%)
Mutual labels:  ctf
Attack-Defense-Platform
A framework that help to create CTF Attack with Defense competition quickly
Stars: ✭ 23 (-68.92%)
Mutual labels:  ctf
Web-Exploitation-Workflow
Web Exploitation Workflow for CTF Challenges
Stars: ✭ 33 (-55.41%)
Mutual labels:  ctf
tosh
Imagine your SSH server only listens on an IPv6 address, and where the last 6 digits are changing every 30 seconds as a TOTP code...
Stars: ✭ 406 (+448.65%)
Mutual labels:  ctf

Inequality Solving with CVP

A special case of this problem has another algorithm : check the "Special Case" folder for details

A full writeup on this toolkit (in Korean) will hopefully be posted for SAMSUNG Software Membership blog.

http://www.secmem.org/blog/2021/03/15/Inequality_Solving_with_CVP/

How to use

The solve function has four inputs, matrix mat, lower/upper bounds lb, ub, and a weight.

Assume mat is an n x m integer matrix. This means there are n variables and m inequalities.

Each column of the mat represents a linear combination of the n variables.

Each entry of lb, ub denotes a lower/upper bound to that linear combination.

Of course, we require the length of lb, ub to be m.

weight is a variable that you do NOT have to initialize. It will be explained later.

result is the result of the CVP

applied_weights is the applied weights during the weighting process (see below)

fin is the actual value of the variables, recovered when n = m and vectors are linearly independent

We also have a heuristic for number of solutions for the inequality. This is a good way to decide if this method is feasible. For some notes on this topic, check out Mystiz's writeup on Example Challenge 5.

The reasoning behind the algorithm

Warning : the stuff I say here are not mathematically precise. It's based on intuition

Basically what the algorithm does, is to build a lattice with the given matrix and find a closest vector (with Babai's algorithm) to (lb + vb) / 2. However, there is one more twist to the algorithm.

The reason we hope that CVP will solve our problem is basically as follows

  • CVP will try to minimize ||x - (lb + vb) / 2|| where x is in our lattice
  • Usually, that implies trying to minimize |x_i - (lb_i + ub_i) / 2| for each i
  • Therefore, it will try to keep |x_i - (lb_i + ub_i) / 2| below |(ub_i - lb_i) / 2|!

However, there's a case where this reasoning fails.

  • Assume we have an instance withlb = [0, 0], ub = [10 ** 300, 1]
  • Does the CVP algorithm "respect" the bound lb_2 = 0, ub_2 = 1?
  • CVP algorithm will ignore it to keep the first entry close to (10 ** 300) / 2 as possible

To do this, we have to scale our inequalities so ub_i - lb_i becomes of similar size.

  • This can be done by multiplying an entire column, as well as lb_i and ub_i
  • What if lb_i = ub_i? Then, we have to multiply a super large integer to that column.
  • This super large integer is the weight in the input.
  • The default weight is what I think is "super large", but you can definitely change it :)

Further Comments

  • Babai's Algorithm implementation is NOT MINE - read solver.sage for details
  • I have included some example challenges I have solved using this technique.
  • You can also break truncated LCG with this idea.
  • This method does not work that well with low density 0/1 knapsack - CJ LOSS is much better.
  • The scaling method (obviously) increases the runtime of the LLL.
  • It seems like sometimes SVP gives better results than CVP...
  • If failed, it's a good idea to try a different scaling by observing the failed output.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].