Skip to content

Instantly share code, notes, and snippets.

View httpmurilo's full-sized avatar
💭
I may be slow to respond.

Murilo Eduardo httpmurilo

💭
I may be slow to respond.
View GitHub Profile
'-'
' '
'&'
'^'
'*'
' or ''-'
' or '' '
' or ''&'
' or ''^'
' or ''*'
@httpmurilo
httpmurilo / Main.java
Last active April 3, 2024 01:28
easy-to-use sql injection with java
public class Main {
public static void main(String[] args) {
String fileName = "nomes.txt";
String baseUrl = "http://localhost:8080/api/user/search?name=";
try (BufferedReader br = new BufferedReader(new FileReader(fileName))) {
String line;
while ((line = br.readLine()) != null) {
String urlWithParam = baseUrl + line.trim();
System.out.println("Fazendo requisição para: " + urlWithParam);
@httpmurilo
httpmurilo / IUserRepository.java
Created April 2, 2024 22:37
IUserRepository.java
public interface IUserRepository extends JpaRepository<User, Integer> {
@Query(value = "SELECT * FROM User WHERE name = '?1'", nativeQuery = true)
User getUserByName(String name);
}
@httpmurilo
httpmurilo / IUserRepository.java
Created April 2, 2024 21:30
IUserRepository.java
public interface IUserRepository extends JpaRepository<User, Integer> {
@Query(value = "SELECT * FROM User WHERE name = ?1", nativeQuery = true)
User getUserByName(String name);
}
@httpmurilo
httpmurilo / IUserRepository.java
Created March 29, 2024 01:17
IUserRepository.java
public interface IUserRepository extends JpaRepository<User, Integer> {
@Query("select u from User u where u.name =:nome ")
User getUserByName(String nome);
}
@httpmurilo
httpmurilo / User.java
Created March 29, 2024 01:16
User.java
@Entity
public class User {
public User() {}
@Id
private int id;
private String name;
@Enumerated(EnumType.STRING)
private Status isActive;
@httpmurilo
httpmurilo / UserController.java
Created March 29, 2024 01:15
UserController.java
@RestController
@RequestMapping("/api/user")
public class UserController {
@Autowired
private IUserRepository repository;
@GetMapping(value = "/search")
public ResponseEntity<User> findByName(@RequestParam String name) {
var user = repository.getUserByName(name);
@httpmurilo
httpmurilo / BuildMaster.java
Created October 5, 2023 00:10
Cria builders de forma automatica
import static java.lang.String.format;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
package com.escola.entidade;
public class Aluno {
public static Aluno criarAlunoComDivisaoPadrao(String nome, Integer idade, String cidade, double notaDeCorte){
return new AlunoSM(nome, idade, cidade, notaDeCorte, 4);
}
//tradicional
private Aluno(String nome, Integer idade, String cidade, double notaDeCorte, Integer dividirPor) {
this.nome = nome;
package com.escola.modelo;
public class Aluno {
public Aluno(String nome, Integer idade, String cidade) {
this.nome = nome;
this.idade = idade;
this.cidade = cidade;
}