Package org.parosproxy.paros.network

Examples of org.parosproxy.paros.network.HttpMessage


 
  private SiteNode accessNode(URL url) {
    SiteNode startNode = null;
      // Request the URL
    try {
      final HttpMessage msg = new HttpMessage(new URI(url.toString(), true));
      getHttpSender().sendAndReceive(msg,true);
   
          if (msg.getResponseHeader().getStatusCode() != HttpStatusCode.OK) {
        extension.notifyProgress(Progress.failed);
              return null;
          }
         
          if (msg.getResponseHeader().isEmpty()) {
            return null;
          }
         
          ExtensionHistory extHistory = ((ExtensionHistory)Control.getSingleton().getExtensionLoader().getExtension(ExtensionHistory.NAME));
          extHistory.addHistory(msg, HistoryReference.TYPE_PROXIED);
         
          SwingUtilities.invokeAndWait(new Runnable(){
        @Override
        public void run() {
          // Needs to be done on the EDT
              Model.getSingleton().getSession().getSiteTree().addPath(msg.getHistoryRef());
        }});
     
      for (int i=0; i < 10; i++) {
        startNode = Model.getSingleton().getSession().getSiteTree().findNode(new URI(url.toString(), false));
        if (startNode != null) {
View Full Code Here


    public void init() {
    }
   
    private List<HtmlContext> performAttack (HttpMessage msg, String param, String attack,
        HtmlContext targetContext, int ignoreFlags) {
    HttpMessage msg2 = msg.cloneRequest();
    setParameter(msg2, param, attack);
        try {
      sendAndReceive(msg2);
      } catch (InvalidRedirectLocationException e) {
        // Not an error, just means we probably attacked the redirect location
View Full Code Here

    public void init() {
    }
   
    private List<HtmlContext> performAttack (HttpMessage sourceMsg, String param, String attack,
        HttpMessage sinkMsg, HtmlContext targetContext, int ignoreFlags) {
    HttpMessage sourceMsg2 = sourceMsg.cloneRequest();
    setParameter(sourceMsg2, param, attack);
        try {
      sendAndReceive(sourceMsg2);
    } catch (Exception e) {
      log.error(e.getMessage(), e);
    }
       
    HttpMessage sinkMsg2 = sinkMsg.cloneRequest();
        try {
      sendAndReceive(sinkMsg2);
    } catch (Exception e) {
      log.error(e.getMessage(), e);
    }
View Full Code Here

    }

    @Override
    public void scan() {

        HttpMessage msg = getBaseMsg();
    boolean result = false;
   
    if (!msg.getRequestHeader().isSecure()) {
        // no need to if non-secure page;
        return;
    } else if (msg.getRequestHeader().isImage()) {
        // does not bother if image is cached
        return;
    } else if (msg.getResponseBody().length() == 0) {
        return;
    } else if (HttpStatusCode.isClientError(msg.getResponseHeader().getStatusCode())) {
      // These typically dont return 'real' data, so can be ignored
      return;
    }
   
    if (!matchHeaderPattern(msg, HttpHeader.CACHE_CONTROL, patternNoCache)
View Full Code Here

              List list = getModel().getDb().getTableHistory().getHistoryList(session.getSessionId(), HistoryReference.TYPE_MANUAL);
              int last = list.size();
              for (int index=0;index < last;index++){
                  int v = ((Integer)(list.get(index))).intValue();
                  try {
                        HttpMessage message = getModel().getDb().getTableHistory().read(v).getHttpMessage();

                        if (Type.URL.equals(reqType)) {
                            // URL
                            matcher = pattern.matcher(message.getRequestHeader().getURI().toString());
                            if (matcher.find()) {
                            this.searchPanel.addSearchResult(
                                new SearchResult(message, reqType,
                                    filter, matcher.group()));
                            }
            }
                        if (Type.Request.equals(reqType) ||
                            Type.All.equals(reqType)) {
                            // Request Header
                            matcher = pattern.matcher(message.getRequestHeader().toString());   
                            if (matcher.find()) {
                            this.searchPanel.addSearchResult(
                                new SearchResult(message, reqType,
                                    filter, matcher.group()));
                            }
                            // Request Body
                            matcher = pattern.matcher(message.getRequestBody().toString());   
                            if (matcher.find()) {
                            this.searchPanel.addSearchResult(
                                new SearchResult(message, reqType,
                                    filter, matcher.group()));
                            }
                        }
                        if (Type.Response.equals(reqType) ||
                            Type.All.equals(reqType)) {
                            // Response header
                            matcher = pattern.matcher(message.getResponseHeader().toString());   
                            if (matcher.find()) {
                            this.searchPanel.addSearchResult(
                                new SearchResult(message, reqType,
                                    filter, matcher.group()));
                            }
                            // Response body
                            matcher = pattern.matcher(message.getResponseBody().toString());   
                            if (matcher.find()) {
                            this.searchPanel.addSearchResult(
                                new SearchResult(message, reqType,
                                    filter, matcher.group()));
                            }
View Full Code Here

 
  protected void processHttp(HttpRequestHeader requestHeader, boolean isSecure) throws IOException {

    HttpBody reqBody = null;
    boolean isFirstRequest = true;
    HttpMessage msg = null;
       
        if (isRecursive(requestHeader)) {
            throw new IOException("Recursive request to proxy itself stopped.");
        }
       
        // reduce socket timeout after first read
        inSocket.setSoTimeout(2500);

    do {

      if (isFirstRequest) {
        isFirstRequest = false;
      } else {
          try {
              requestHeader = httpIn.readRequestHeader(isSecure);

          } catch (SocketTimeoutException e) {
            // ZAP: Log the exception
              log.error(e.getMessage(), e);
              return;
          }
      }

      msg = new HttpMessage();
      msg.setRequestHeader(requestHeader);
     
      if (msg.getRequestHeader().getContentLength() > 0) {
        reqBody    = httpIn.readBody(requestHeader);
        msg.setRequestBody(reqBody);
      }
           
      modifyHeader(msg);
           
            if (isProcessCache(msg)) {
                continue;
            }
         
//            System.out.println("send required: " + msg.getRequestHeader().getURI().toString());
           
      if (parentServer.isSerialize()) {
          semaphore = semaphoreSingleton;
      } else {
          semaphore = this;
      }
     
      synchronized (semaphore) {
         
          notifyListenerRequestSend(msg);
         
         
          try {

//          bug occur where response cannot be processed by various listener
//              first so streaming feature was disabled           
//          getHttpSender().sendAndReceive(msg, httpOut, buffer);

          getHttpSender().sendAndReceive(msg);
              notifyListenerResponseReceive(msg);
             
              // write out response header and body
              httpOut.write(msg.getResponseHeader());
                httpOut.flush();
             
              if (msg.getResponseBody().length() > 0) {
                  httpOut.write(msg.getResponseBody().getBytes());
                  httpOut.flush();
              }
             
//              notifyWrittenToForwardProxy();
             
View Full Code Here

            return false;
        }
       
        CacheProcessingItem item = (CacheProcessingItem) parentServer.getCacheProcessingList().get(0);
        if (msg.equals(item.message)) {
            HttpMessage newMsg = item.message.cloneAll();
            msg.setResponseHeader(newMsg.getResponseHeader());
            msg.setResponseBody(newMsg.getResponseBody());

            httpOut.write(msg.getResponseHeader());
            httpOut.flush();

            if (msg.getResponseBody().length() > 0) {
View Full Code Here

          public void actionPerformed(java.awt.event.ActionEvent e) {   

                if (treeSite != null) {
                SiteNode node = (SiteNode) treeSite.getLastSelectedPathComponent();

                HttpMessage msg = null;
                if (node == null) {
                    return;
                }
                    try {
                        msg = node.getHistoryReference().getHttpMessage();
                    } catch (Exception e1) {
                      log.warn(e1.getMessage(), e1);
                        return;
                    }
                    String tmp = msg.getRequestHeader().getURI().toString();
                    if ( ! node.isLeaf()) {
                      tmp += "/*";
                    }
                    extension.showBreakAddDialog(tmp);
                }
View Full Code Here

      resultsList.requestFocus();
    }
    }
   
    private void displayMessage(SearchResult sr) {
        HttpMessage msg = sr.getMessage();
        if (msg.getRequestHeader().isEmpty()) {
            requestPanel.setMessage(null, true);
        } else {
            requestPanel.setMessage(msg, true);
        }
       
        if (msg.getResponseHeader().isEmpty()) {
            responsePanel.setMessage(null, false);
        } else {
            responsePanel.setMessage(msg, false);
        }
        highlightFirstResult(sr);
View Full Code Here

          public void actionPerformed(java.awt.event.ActionEvent e) {
             
              JList listLog = extension.getLogPanel().getListLog();
              HistoryReference ref = (HistoryReference) listLog.getSelectedValue();
              HttpMessage msg = null;
              try {
                    msg = ref.getHttpMessage();
                  extension.showManageTagsDialog(ref, msg.getTags());
                } catch (HttpMalformedHeaderException e1) {
                    e1.printStackTrace();
                } catch (SQLException e1) {
                    e1.printStackTrace();
                }
View Full Code Here

TOP

Related Classes of org.parosproxy.paros.network.HttpMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.