Skip to content
KitploitKITPLOIT
उपकरणब्लॉग
जमा करें
उपकरणब्लॉग
जमा करें

हैकिंग, पेनटेस्ट और साइबर सुरक्षा उपकरण आपके सुरक्षा शस्त्रागार के लिए!

Kitploit हैकिंग, साइबर सुरक्षा और पेंटेस्टिंग टूल्स की एक निर्देशिका है। कमजोरियों को खोजने, सिस्टम का विश्लेषण करने, परीक्षण को स्वचालित करने और अपनी सुरक्षा को मजबूत करने के लिए नवीनतम प्रोजेक्ट अपडेट खोजें।

··फ़ीड·संपर्क·गोपनीयता·© 2026 Kitploit

टूल निर्देशिका

श्रेणियाँ

सभी श्रेणियाँ देखें
Loading categories
perwendel__spark_CVE-2018-9159_2-7-1 — हल्का Java 8 वेब फ्रेमवर्क जिसमें रूटिंग, फिल्टर और स्थैतिक फ़ाइल सेवा शामिल है। इसमें पुराने संस्करणों के लिए सुरक्षा सलाह और CRUD API उदाहरण शामिल हैं। | Kitploit
उपकरण/GitHubGitHub/shoucheng3/perwendel__spark_cve-2018-9159_2-7-1
सामान्य उपयोगिताएँभेद्यता विश्लेषणएपीआई सुरक्षा परीक्षणवेब सुरक्षापेनिट्रेशन टेस्टिंगलर्निंग और शिक्षा
GitHubshoucheng3/perwendel__spark_cve-2018-9159_2-7-1

perwendel__spark_CVE-2018-9159_2-7-1

हल्का Java 8 वेब फ्रेमवर्क जिसमें रूटिंग, फिल्टर और स्थैतिक फ़ाइल सेवा शामिल है। इसमें पुराने संस्करणों के लिए सुरक्षा सलाह और CRUD API उदाहरण शामिल हैं।

सबसे लोकप्रिय

सभी देखें →

हमारे समुदाय द्वारा सबसे अधिक उपयोग किए जाने वाले उपकरण खोजें।

सभी उपकरण खोजें

हमारे उपकरणों का संग्रह ब्राउज़ करें

सभी उपकरण देखें →
साझा करें
रिपॉजिटरी देखें
1 साल पहलेअभी तक समीक्षित नहीं

Spark - जावा 8 के लिए एक छोटा वेब फ्रेमवर्क

समाचार: Spark 2.7.0 जारी किया गया है। कृपया इसे आज़माएं और किसी भी बग की रिपोर्ट करें।

root@kitploit:~
<dependency>
    <groupId>com.sparkjava</groupId>
    <artifactId>spark-core</artifactId>
    <version>2.7.0</version>
</dependency>

महत्वपूर्ण - Spark के पुराने संस्करणों (2.5.2 से निचले संस्करण) में एक भेद्यता है। कृपया नवीनतम संस्करण में अपग्रेड करें।

दस्तावेज़ीकरण के लिए कृपया जाएँ: http://sparkjava.com/documentation

उपयोग संबंधी प्रश्नों के लिए, कृपया “spark-java” टैग के साथ स्टैक ओवरफ़्लो का उपयोग करें

Javadoc: http://javadoc.io/doc/com.sparkjava/spark-core

आरंभ करना

root@kitploit:~
<dependency>
    <groupId>com.sparkjava</groupId>
    <artifactId>spark-core</artifactId>
    <version>2.7.0</version>
</dependency>
root@kitploit:~
import static spark.Spark.*;

public class HelloWorld {
    public static void main(String[] args) {
        get("/hello", (request, response) -> "Hello World!");
    }
}

देखें: http://localhost:4567/hello

स्रोत कोड में उदाहरणों को देखें और आज़माएं। आप javadoc भी देख सकते हैं। स्रोत प्राप्त करने के बाद github से चलाएँ:

root@kitploit:~
mvn javadoc:javadoc

परिणाम /target/site/apidocs में रखा जाता है

उदाहरण

कुछ बुनियादी कार्यक्षमता दिखाने वाला सरल उदाहरण

root@kitploit:~
import static spark.Spark.*;

/**
 * A simple example just showing some basic functionality
 */
public class SimpleExample {

    public static void main(String[] args) {

        //  port(5678); <- Uncomment this if you want spark to listen to port 5678 instead of the default 4567

        get("/hello", (request, response) -> "Hello World!");

        post("/hello", (request, response) ->
            "Hello World: " + request.body()
        );

        get("/private", (request, response) -> {
            response.status(401);
            return "Go Away!!!";
        });

        get("/users/:name", (request, response) -> "Selected user: " + request.params(":name"));

        get("/news/:section", (request, response) -> {
            response.type("text/xml");
            return "<?xml version=\"1.0\" encoding=\"UTF-8\"?><news>" + request.params("section") + "</news>";
        });

        get("/protected", (request, response) -> {
            halt(403, "I don't think so!!!");
            return null;
        });

        get("/redirect", (request, response) -> {
            response.redirect("/news/world");
            return null;
        });

        get("/", (request, response) -> "root");
    }
}


पुस्तक संसाधनों को बनाने, प्राप्त करने, अद्यतन करने और हटाने का तरीका दिखाने वाला एक सरल CRUD उदाहरण

root@kitploit:~
import static spark.Spark.*;

import java.util.HashMap;
import java.util.Map;
import java.util.Random;

/**
 * A simple CRUD example showing how to create, get, update and delete book resources.
 */
public class Books {

    /**
     * Map holding the books
     */
    private static Map<String, Book> books = new HashMap<String, Book>();

    public static void main(String[] args) {
        final Random random = new Random();

        // Creates a new book resource, will return the ID to the created resource
        // author and title are sent in the post body as x-www-urlencoded values e.g. author=Foo&title=Bar
        // you get them by using request.queryParams("valuename")
        post("/books", (request, response) -> {
            String author = request.queryParams("author");
            String title = request.queryParams("title");
            Book book = new Book(author, title);

            int id = random.nextInt(Integer.MAX_VALUE);
            books.put(String.valueOf(id), book);

            response.status(201); // 201 Created
            return id;
        });

        // Gets the book resource for the provided id
        get("/books/:id", (request, response) -> {
            Book book = books.get(request.params(":id"));
            if (book != null) {
                return "Title: " + book.getTitle() + ", Author: " + book.getAuthor();
            } else {
                response.status(404); // 404 Not found
                return "Book not found";
            }
        });

        // Updates the book resource for the provided id with new information
        // author and title are sent in the request body as x-www-urlencoded values e.g. author=Foo&title=Bar
        // you get them by using request.queryParams("valuename")
        put("/books/:id", (request, response) -> {
            String id = request.params(":id");
            Book book = books.get(id);
            if (book != null) {
                String newAuthor = request.queryParams("author");
                String newTitle = request.queryParams("title");
                if (newAuthor != null) {
                    book.setAuthor(newAuthor);
                }
                if (newTitle != null) {
                    book.setTitle(newTitle);
                }
                return "Book with id '" + id + "' updated";
            } else {
                response.status(404); // 404 Not found
                return "Book not found";
            }
        });

        // Deletes the book resource for the provided id
        delete("/books/:id", (request, response) -> {
            String id = request.params(":id");
            Book book = books.remove(id);
            if (book != null) {
                return "Book with id '" + id + "' deleted";
            } else {
                response.status(404); // 404 Not found
                return "Book not found";
            }
        });

        // Gets all available book resources (ids)
        get("/books", (request, response) -> {
            String ids = "";
            for (String id : books.keySet()) {
                ids += id + " ";
            }
            return ids;
        });
    }

    public static class Book {

        public String author, title;

        public Book(String author, String title) {
            this.author = author;
            this.title = title;
        }

        public String getAuthor() {
            return author;
        }

        public void setAuthor(String author) {
            this.author = author;
        }

        public String getTitle() {
            return title;
        }

        public void setTitle(String title) {
            this.title = title;
        }
    }
}

एक बहुत ही सरल (और बेवकूफी भरा) प्रमाणीकरण फ़िल्टर दिखाने वाला उदाहरण जो अन्य सभी संसाधनों से पहले निष्पादित किया जाता है

root@kitploit:~
import static spark.Spark.*;

import java.util.HashMap;
import java.util.Map;

/**
 * Example showing a very simple (and stupid) authentication filter that is
 * executed before all other resources.
 *
 * When requesting the resource with e.g.
 *     http://localhost:4567/hello?user=some&password=guy
 * the filter will stop the execution and the client will get a 401 UNAUTHORIZED with the content 'You are not welcome here'
 *
 * When requesting the resource with e.g.
 *     http://localhost:4567/hello?user=foo&password=bar
 * the filter will accept the request and the request will continue to the /hello route.
 *
 * Note: There is a second "before filter" that adds a header to the response
 * Note: There is also an "after filter" that adds a header to the response
 */
public class FilterExample {

    private static Map<String, String> usernamePasswords = new HashMap<String, String>();

    public static void main(String[] args) {

        usernamePasswords.put("foo", "bar");
        usernamePasswords.put("admin", "admin");

        before((request, response) -> {
            String user = request.queryParams("user");
            String password = request.queryParams("password");

            String dbPassword = usernamePasswords.get(user);
            if (!(password != null && password.equals(dbPassword))) {
                halt(401, "You are not welcome here!!!");
            }
        });

        before("/hello", (request, response) -> response.header("Foo", "Set by second before filter"));

        get("/hello", (request, response) -> "Hello World!");

        after("/hello", (request, response) -> response.header("spark", "added by after-filter"));

        afterAfter("/hello", (request, response) -> response.header("finally", "executed even if exception is throw"));

        afterAfter((request, response) -> response.header("finally", "executed after any route even if exception is throw"));
    }
}

विशेषताओं का उपयोग करने का तरीका दिखाने वाला उदाहरण

root@kitploit:~
import static spark.Spark.after;
import static spark.Spark.get;

/**
 * Example showing the use of attributes
 */
public class FilterExampleAttributes {

    public static void main(String[] args) {
        get("/hi", (request, response) -> {
            request.attribute("foo", "bar");
            return null;
        });

        after("/hi", (request, response) -> {
            for (String attr : request.attributes()) {
                System.out.println("attr: " + attr);
            }
        });

        after("/hi", (request, response) -> {
            Object foo = request.attribute("foo");
            response.body(asXml("foo", foo));
        });
    }

    private static String asXml(String name, Object value) {
        return "<?xml version=\"1.0\" encoding=\"UTF-8\"?><" + name +">" + value + "</"+ name + ">";
    }
}

स्थैतिक संसाधनों को प्रस्तुत करने का तरीका दिखाने वाला उदाहरण

root@kitploit:~
import static spark.Spark.*;

public class StaticResources {

    public static void main(String[] args) {

        // Will serve all static file are under "/public" in classpath if the route isn't consumed by others routes.
        // When using Maven, the "/public" folder is assumed to be in "/main/resources"
        staticFileLocation("/public");

        get("/hello", (request, response) -> "Hello World!");
    }
}

स्वीकार्य प्रकार के आधार पर सामग्री को परिभाषित करने का तरीका दिखाने वाला उदाहरण

root@kitploit:~
import static spark.Spark.*;

public class JsonAcceptTypeExample {

    public static void main(String args[]) {

        //Running curl -i -H "Accept: application/json" http://localhost:4567/hello json message is read.
        //Running curl -i -H "Accept: text/html" http://localhost:4567/hello HTTP 404 error is thrown.
        get("/hello", "application/json", (request, response) -> "{\"message\": \"Hello World\"}");
    }
} 

एक टेम्पलेट से दृश्य प्रस्तुत करने का तरीका दिखाने वाला उदाहरण। ध्यान दें कि हम ऑब्जेक्ट और टेम्पलेट का नाम/स्थान सेट करने के लिए ModelAndView क्लास का उपयोग कर रहे हैं।

सबसे पहले हम एक क्लास परिभाषित करते हैं जो उपयोग किए गए टेम्पलेट इंजन के आधार पर आउटपुट को संभालता और प्रस्तुत करता है। इस मामले में FreeMarker.

root@kitploit:~
public class FreeMarkerTemplateEngine extends TemplateEngine {

    private Configuration configuration;

    protected FreeMarkerTemplateEngine() {
        this.configuration = createFreemarkerConfiguration();
    }

    @Override
    public String render(ModelAndView modelAndView) {
        try {
            StringWriter stringWriter = new StringWriter();

            Template template = configuration.getTemplate(modelAndView.getViewName());
            template.process(modelAndView.getModel(), stringWriter);

            return stringWriter.toString();
        } catch (IOException e) {
            throw new IllegalArgumentException(e);
        } catch (TemplateException e) {
            throw new IllegalArgumentException(e);
        }
    }

    private Configuration createFreemarkerConfiguration() {
        Configuration retVal = new Configuration();
        retVal.setClassForTemplateLoading(FreeMarkerTemplateEngine.class, "freemarker");
        return retVal;
    }
}

फिर हम इसका उपयोग अपनी सामग्री उत्पन्न करने के लिए कर सकते हैं। ध्यान दें कि हम मॉडल डेटा और व्यू नाम कैसे सेट कर रहे हैं। क्योंकि हम FreeMarker का उपयोग कर रहे हैं, इस मामले में एक Map और टेम्पलेट का नाम आवश्यक है:

root@kitploit:~
public class FreeMarkerExample {

    public static void main(String args[]) {

        get("/hello", (request, response) -> {
            Map<String, Object> attributes = new HashMap<>();
            attributes.put("message", "Hello FreeMarker World");

            // The hello.ftl file is located in directory:
            // src/test/resources/spark/examples/templateview/freemarker
            return modelAndView(attributes, "hello.ftl");
        }, new FreeMarkerTemplateEngine());
    }
}

ट्रांसफॉर्मर का उपयोग करने का उदाहरण।

सबसे पहले हम ट्रांसफॉर्मर क्लास को परिभाषित करते हैं, इस मामले में एक क्लास जो gson API का उपयोग करके किसी ऑब्जेक्ट को JSON प्रारूप में रूपांतरित करता है।

root@kitploit:~
public class JsonTransformer implements ResponseTransformer {

	private Gson gson = new Gson();

	@Override
	public String render(Object model) {
		return gson.toJson(model);
	}
}

और फिर वह कोड जो JSON में रूपांतरित होने के लिए एक सरल POJO लौटाता है:

root@kitploit:~
public class TransformerExample {

    public static void main(String args[]) {
        get("/hello", "application/json", (request, response) -> {
            return new MyMessage("Hello World");
        }, new JsonTransformer());
    }
}

डीबगिंग

Spark-debug-tools को एक अलग मॉड्यूल के रूप में देखें।

टूल डाउनलोड करें