View Javadoc
1   /*******************************************************************************
2    * Copyhacked (H) 2012-2020.
3    * This program and the accompanying materials
4    * are made available under no term at all, use it like
5    * you want, but share and discuss about it
6    * every time possible with every body.
7    * 
8    * Contributors:
9    *      ron190 at ymail dot com - initial implementation
10   ******************************************************************************/
11  package com.jsql.view.terminal.interaction;
12  
13  import com.jsql.model.InjectionModel;
14  import com.jsql.model.bean.util.Header;
15  import com.jsql.util.AnsiColorUtil;
16  import com.jsql.view.interaction.InteractionCommand;
17  import org.apache.logging.log4j.LogManager;
18  import org.apache.logging.log4j.Logger;
19  
20  import java.util.Map;
21  
22  /**
23   * Mark the injection as vulnerable to a error-based injection.
24   */
25  public class MarkErrorVulnerable implements InteractionCommand {
26      
27      private static final Logger LOGGER = LogManager.getRootLogger();
28      
29      private final int indexMethodError;
30      private final InjectionModel injectionModel;
31      
32      @SuppressWarnings("unchecked")
33      public MarkErrorVulnerable(Object[] interactionParams) {
34          
35          Map<Header, Object> mapHeader = (Map<Header, Object>) interactionParams[0];
36          this.indexMethodError = (int) mapHeader.get(Header.INDEX_ERROR_STRATEGY);
37          this.injectionModel = (InjectionModel) mapHeader.get(Header.INJECTION_MODEL);
38      }
39  
40      @Override
41      public void execute() {
42          LOGGER.info(
43              () -> AnsiColorUtil.addGreenColor(
44                  this.injectionModel
45                  .getMediatorVendor()
46                  .getVendor()
47                  .instance()
48                  .getModelYaml()
49                  .getStrategy()
50                  .getError()
51                  .getMethod()
52                  .get(this.indexMethodError)
53                  .getName()
54              )
55          );
56      }
57  }